r/PythonLearning • • Oct 27 '24

Why isnt this working?

Post image

Yes I know I can print screen but i cant be bothered to log in on the laptop

0 Upvotes

8 comments sorted by

View all comments

5

u/Rageinjector Oct 27 '24 edited Oct 27 '24

Brand new to python but I see a few things. Your - should be in quotes(single or double, your choice) in your if line, also the colon should be immediately after the last character of whatever you type on any line, no space. .. You may also want to write it as a f-string

if operator == "-":

print(f"The answer to {num1} {operator} {num2} is {num1 - num2}")

elif operator == "+":

print(f"The answer to {num1} {operator} {num2} is {num1 + num2}")

Etc.

Edit: formatting from mobile