Python Forum
If & Else statements not printing.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
If & Else statements not printing.
#1
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
Reply
#2
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.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
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
Reply
#4
Thank you it worked.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to aling the printing statements Mekala 4 2,320 May-16-2020, 05:41 AM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020