0

Why is my code showing errors

birth _ year= input ("enter your birth year") age= 2020 int (birth year) print (age)

25th Oct 2024, 7:34 AM
Comfort Anyigor
Comfort Anyigor - avatar
3 Answers
+ 1
# Hi Comfort Anyigor, # Take a look at this one: birth_year = int(input("Enter your birth year: ")) this_year = 2024 age = this_year - birth_year print("Your age is about", age, "years.")
25th Oct 2024, 8:08 AM
Per Bratthammar
Per Bratthammar - avatar
0
In the code you provided, there are a number of errors. birth _ year= input ("enter your birth year") age= 2020 int (birth year) print (age) You provided THREE lines of code. First line, there are spaces around the _ Variables may not have spaces. It should read birth_year, not birth _ year In the second line, you wanted: age = 2020 - int(birth_year) You left out the _ there. Keep in mind that variables have names and those names have to be used consistently to reference them. On line 1, you want to store a value into a variable. On line two you want to read the value from that variable. The name of your variable has to be written exactly the same in all places and have to follow a few rules, such as cannot contain spaces.
25th Oct 2024, 1:34 PM
Jerry Hobby
Jerry Hobby - avatar
0
Your code has a few syntax errors birth_year = int(input("Enter your birth year: ")) age = 2020 - birth_year print(age)
25th Oct 2024, 2:48 PM
Amelia
Amelia - avatar