Reputation: 995
So I'm messing around with idle and wrote a silly program:
name = "none"
phone = "none"
while phone == "none":
phone = str(input("Please enter your phone number formatted as (111)111-111 "))
print("loading...")
while name == "none":
name = str(input("Please enter your full name formatted as First, Last "))
print("Thank you for entering your information. Is this correct?")
print("Phone: ", phone, "Name: ", name)
yesno = str(input("Please Enter 'yes', or 'no' to confirm this information."))
if yesno == "yes":
print("Thank you for your time! Your data has been successfully submitted.")
else:
print("Sorry. Please reload the program and enter your data again")
but when I run it I get the error: Unexpected EOF.
It seems to work when I only use numbers and no punctuation. Why cant I pass punctuation like (), in my code?
Upvotes: 0
Views: 83
Reputation: 3192
python3 test.py
Please enter your phone number formatted as (111)111-111 555 555 5555
loading...
Please enter your full name formatted as First, Last joe, schmoe
Thank you for entering your information. Is this correct?
Phone: 555 555 5555 Name: joe, schmoe
Please Enter 'yes', or 'no' to confirm this information.yes
Thank you for your time! Your data has been successfully submitted.
So, it works fine as in in py3.
Upvotes: 0
Reputation: 250881
You're running your code in Python2, where input
is equivalent to eval(raw_input())
. So, it is going to throw EOF errors for invalid identifiers.
>>> input()
1sdfsdf
File "<string>", line 1
1sdfsdf
^
SyntaxError: unexpected EOF while parsing
So, either run your code in Python3 or use raw_input
for Python2.(Note that the str
call is redundant if you're going to use Python3.)
Upvotes: 4