0
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

asked Jan 24, 2016 at 12:51
2
  • 1
    missing right parenthesis after str, should be str(input("Enter yes or no")). Commented Jan 24, 2016 at 12:52
  • Maya, read the official Python tutorial , it will help you a lot with these small syntactic mistakes. Commented Jan 24, 2016 at 12:58

2 Answers 2

1

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()
answered Jan 24, 2016 at 12:54
Sign up to request clarification or add additional context in comments.

1 Comment

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?
1

As pointed by Jim, You need to write as:

quiz_again = str(input("Enter yes or no"))
answered Jan 24, 2016 at 12:55

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.