-1

Why this code is not working?

font = pygame.font.SysFont(None, 24)
zahl = 99
img = font.render(("zahl  ",str(zahl)), True, WHITE)
screen.blit(img, (20, 20))enter code here

I get the message: TypeError: text must be a unicode or bytes

Best regards Joachim

Rabbid76
  • 202,892
  • 27
  • 131
  • 174
Joachim
  • 375
  • 1
  • 12

1 Answers1

1

("zahl ",str(zahl)) is a tuple. render expects either a string or a bytes instance. Try this:

img = font.render("zahl  " + str(zahl), True, WHITE)
Solomon Slow
  • 25,130
  • 5
  • 37
  • 57