Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using a flag error
#1
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 '' :)
Reply
#2
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 """
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Big Grin Variable flag vs code outside of for loop?(Disregard) cubangt 2 1,166 Mar-16-2022, 08:54 PM
Last Post: cubangt
  how to check for thread kill flag nanok66 1 2,170 May-09-2020, 10:06 PM
Last Post: nanok66
  Check for a special characters in a column and flag it ayomayam 0 2,043 Feb-12-2020, 03:04 PM
Last Post: ayomayam
  Identifying string success flag graham23s 4 3,102 Aug-14-2019, 09:27 PM
Last Post: graham23s
  Practicing using a "flag": please point in right direction magsloo 5 3,076 May-10-2019, 04:58 AM
Last Post: perfringo
  How to make an activation flag? Krszt 4 3,283 Oct-11-2018, 09:39 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020