Apparently I have a syntax error please help

+1 Ian Wheeler · April 9, 2015
I am trying to make a program that will "guess" your age it really just uses algorithms to get your age anyways I ran into a syntax error and I have checked it many times I still don't know what it is. Please check this and tell me what you think is wrong and put the correct code please. Here is the code.


Num=int(input("Enter a number 1-10: "))
M1=Num*2
M2=M1+5
M3=M2*50
ADD=raw_input("Have you had your birthday this year? Yes or No?: ")
if ADD=='Yes' or ADD=='yes':
    M4=M3+1765
if ADD=='No' or ADD=='no':
    M4=M3+1764
    
BY=int(input("What year were you born in? Put in numbers.: ")
M5=M4-BY 
print("")+M5
       
raw_input("Press<Enter>to exit")

Post a Reply

Replies

Oldest  Newest  Rating
+1 Dake O'Dowd · April 13, 2015
Hello Ian Wheeler,
I found a few things wrong with this code. The first thing I notice right away was that you forgot to place an ending parenthesis on the int, where you declared "BY". The other thing I noticed was, which is not a error, is that when you print "M5" you do not have place the '("")+' next to the M5. I think I was able to fix the error. Why I say 'I think' is because I used Python 2.7, and what you provide does not accomplish what you are seeking. Lastly here is your code that should be fixed.


Num=int(input("Enter a number 1-10: "))
M1=Num*2
M2=M1+5
M3=M2*50
ADD=raw_input("Have you had your birthday this year? Yes or No?: ")
if ADD=='Yes' or ADD=='yes':
    M4=M3+1765
elif ADD=='No' or ADD=='no':
    M4=M3+1764
BY=int(input("What year were you born in? Put in numbers.: "))
M5=M4-BY
print M5

raw_input("Press to exit")



I hope this works,
~Dake O'Dowd
P.s. You're the first I have replied to yet.
0 Bernard Pyc0d333 Parah · April 13, 2015
This is python2
print ("string") for python 3
0 Dol Lod · April 9, 2015
If you have an error in python, you need to use code tags. Python is based on indentation. However, in this post, everything is aligned including if statements so it is impossible to give a baisc kind of syntax error.

Additionally, you should specify a python version between 2 and 3. I am assuming Python3 b/c of the print but I could be wrong. 

Test it at ideone.com.
0 Juan Grasso · April 10, 2015
I think that you are minxin pyhotn 2 and 3 syntax
  • 1

Python

103,771 followers
About

This section is all about snakes! Just kidding.

Links
Moderators
Bucky Roberts Administrator