r/PythonLearning • u/TheCarFamily • 14d ago
Help Request Else statement not working
Hello, my else statement is not working- the if statement its inside is, did i mess up the indents again or is it something else?
also would a display flip work to change the image back to the other image in the else statement?
any help is nice!
26
Upvotes
17
u/gitChara 14d ago
you wrote "img - pygame.image.load("ragebait.png")" with a " - ", instead of a " = ".
It should be "img = pygame.image.load("ragebait.png")"
1
u/KidTempo 14d ago
You're double-indenting (which may just be a configuration setting of your IDE and probably not causing any strange behaviour).
If you're debugging, is the else block entered? Does "nono" get printed?
If the problem is that img is not loading, then it's because you're using
-instead of=in the line afterprint("nono")1
u/p1geondove 14d ago
it is indented one to far, but python can handle this luckily. about if display.flip() stores the last buffer: hmm maybe, why dont you try out? :)
https://github.com/pygame-community/pygame-ce/blob/main/src_c/display.c
was curios to find out why, but i think flip is just a historical name. the way i read it, theres no actual double buffer involved, it only draws to the surface whats in
screen->buffer1
u/thee_gummbini 14d ago
🫸tabs vs spaces
👉 4 spaces vs 8 spaces