Python Forum
If & Else statements not printing. - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: If & Else statements not printing. (/thread-23909.html)



If & Else statements not printing. - blackjesus24 - Jan-22-2020

Hi fellow developers, so i just started coding with Python.

I am trying to print a " If or Else, statement " and is just not letting me print, telling me i did something wrong. Can't seem to figure it out.. Doh


score = 99
if score == 100:
 print ("Congrat, u reached 100")
 else:
 print("Almost at 100")
Print box:

Error:
Syntax:Error: Invalid syntax [Finished in 0.0s with exit code 1]
Forgive me if i am a noob Big Grin


RE: If & Else statements not printing. - buran - Jan-22-2020

Please, don't post images of code
Copy/paste your code in python tags
copy/paste full traceback, if you get one - in error tags

See BBcode help for more info.


RE: If & Else statements not printing. - sandeep_ganga - Jan-22-2020

I doubt indentation is erroring you, try below to see if that helps

score=99
if score == 100:
	print(f"congrats, you reached {score}\n")
else:
	print("Almost at 100\n")
Output:
python test1.py Almost at 100
Best Regards,
Sandeep

GANGA SANDEEP KUMAR


RE: If & Else statements not printing. - blackjesus24 - Jan-22-2020

Thank you it worked.