Python Forum

Full Version: Using a flag error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, i'm trying to print my code, but i keep getting syntax error.

prompt = "\nEnter "q" to end this program."
prompt += "\nWhat is your name? "

active = True
while active:
    message = input(prompt)

    if message == "q":
        active = False
    else:
        print(message)
I solved it, all i did was change the "" to '' :)
on line 1 - you cannot have double quotes within string with double quotes.
You can use single quotes instead
prompt = '\nEnter "q" to end this program.'
read the docs about using single quotes ', double quotes " and tripple quotes ''' or """