r/pythonhelp • u/ShovelKillers • Apr 18 '21
Hello, I'm very new to python and I'm following a YouTube video on making simple code. Can someone explain to me why I'm getting a syntax error here seemingly on the print statement?
4
Upvotes
3
u/scoopulanang Apr 18 '21
Your problem occurs because of your if statement.
if age_older = age>= 18:First off, you use two equal signs to compare within if statements. A single equal sign is an assignment operator. Also, age_older is not defined so your program won't work. Just do something like this:
if age>=18:Also you have two else statements, which means one of them won't run. Another thing to consider, I would learning and using f-strings. It makes your print statements and other strings look much neater. In your code, we can do this:
print(f'Hello {name} you are {age} years old')0
7
u/someoneonboard1 Apr 18 '21
Missing closing bracket on line 3