Python Forum
Getting syntax error, no clue why - 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: Getting syntax error, no clue why (/thread-17053.html)



Getting syntax error, no clue why - KaynRyu - Mar-26-2019

I dont know if I am just dumb and not seeing what is going on but I am so confused.....

the issue I am having is
 birthday = input("Have you had your birthday this year? ")
and getting a syntax error pointing at the variable name. What is going on? the two lines previous look exactly the same and are not having any issues.


RE: Getting syntax error, no clue why - buran - Mar-26-2019

Often with the SyntaxError the error is indeed on the line before where it is indicated.
Post the full code or at least couple of lines before and after that one


RE: Getting syntax error, no clue why - KaynRyu - Mar-26-2019

its not a very long script, and it is fairly simple so i will just post all of it.
import time
from datetime import date

name = input("What is your name? ")
age = int(input("How old are you? ")
birthday = input("Have you had a birthday this year? ")

if birthday == "yes" and age != "":
    oldAge = (date.today().year - age) + 100
elif birthday == "no" and age != "":
    oldAge = (date.today().year - (age + 1)) + 100
else:
    print("Your age must be a number!")

output = f"Your name is {name}, and you will be 100 years old in {oldAge}!"
print(output)

repeat = input("Pick a number between 1 and 100: ")
count = 0

if int(repeat) > 0:
    for num in range(int(repeat)):
        print(output + "\n")



RE: Getting syntax error, no clue why - buran - Mar-26-2019

yep, there is missing closing bracket on line 5


RE: Getting syntax error, no clue why - KaynRyu - Mar-26-2019

Oh my gosh, thank you.... simple mistakes amiright. lol. This makes me sad as I have been coding in python everyday for over a month and this is probably the simplest thing I have done in a few weeks and it was just driving me nuts. Thank you.