Saturday, 14 September 2013

i keep getting a Value error in python

i keep getting a Value error in python

I am new to programming and m just starting a GCSE in computer programming
I decided I would make a basic maths game. I started with this code.
#Callum Dashfield 12/09/2-13
print ("what is your name")
name = input ()
print ("hello " + name + " i am steve and this is my maths test. Are
you ready? Y/N")
answer_1 = input ()
answer_1 = int (answer_1)
if answer_1 ==Y:
print ("Good then lets get started")
else:
print ("well you have started now so to late lets go")
I went to test it and every time I do I get this.
what is your name
Callum
hello Callum i am steve and this is my maths test. Are you ready? Y/N
Y
Traceback (most recent call last):
File "C:\Users\callum\Documents\programming\maths test.py", line 6,
in <module>
answer_1 = int (answer_1)
ValueError: invalid literal for int() with base 10: 'Y'
>>>
Can anyone tell me what I have done wrong

No comments:

Post a Comment