0

In my game, I want to make a score function. How to make it to display variables in the pgzero text funtion

the code to display text is: screen.draw.text(score, (70, 30), color="orange") but an error comes up like this: AttributeError: 'int' object has no attribute 'replace'

how can I display a variable in the screen.draw.text function?

CodeWizard777
  • 71
  • 1
  • 10

1 Answers1

0

You must provide a string to the text function. Your score variable probably contains an int value. Use the str function to convert the contents of the score variable to a string:

screen.draw.text(str(score), (70, 30), color="orange")
r0the
  • 617
  • 4
  • 13