r/pythonhelp • • 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?

Post image
4 Upvotes

6 comments sorted by

7

u/someoneonboard1 Apr 18 '21

Missing closing bracket on line 3

2

u/structurefall Apr 18 '21

This is what's actually causing the error you're seeing right now. You have two open parentheses and only one closed on line 3.

Line 7 is also a problem. Don't try to do the assignment and the comparison at the same time, make that two separate lines.

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

u/[deleted] Apr 18 '21

try + instead of ,

2

u/structurefall Apr 18 '21

Both are acceptable, this isn't a problem.