quiz_again = str(input("Enter yes or no")
if quiz_again == "yes":
quiz()
I am tying to run this on python (idle version 3.4.2) but I am greeted with syntax error: invalid syntax and the cursor highlights the ":" If anyone could explain I would be very appreciative
2 Answers 2
You have an indentation issue. If a function quiz is defined, try it:
quiz_again = str(input("Enter yes or no"))
if quiz_again == "yes":
quiz()
or it's possible to run:
quiz_again = str(input("Enter yes or no"))
if quiz_again == "yes": quiz()
Sign up to request clarification or add additional context in comments.
1 Comment
Matthias
Second version is ugly and does not confirm to the Style Guide for Python Code. And why do you keep the call to
str and don't explain that you don't need it because the return value of input is already a string?As pointed by Jim, You need to write as:
quiz_again = str(input("Enter yes or no"))
answered Jan 24, 2016 at 12:55
dlmeetei
10.5k3 gold badges35 silver badges39 bronze badges
Comments
lang-py
str, should bestr(input("Enter yes or no")).