Python Forum
inserting input gives me error message
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
inserting input gives me error message
#1
I keep getting this error message
Error:
Traceback (most recent call last): File "U:/Computer Programming/Python/Quiz how.py", line 3, in <module> if (answer_1 == Flat): NameError: name 'Flat' is not defined
My Code is
score = 0
answer_1 = input("What is the shape of the Earth?")
if (answer_1 == Flat):
    print("You got it right")
    score = score + 1
    print("Your Score is:", score)
else:
    print("You are incorrect, The answer was Flat")
    print("Your Score is:", score)
please help me
Reply
#2
please, read https://python-forum.io/Thread-Python3-2...-raw-input

I overlooked the traceback. See the answer in next post
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
#3
quotation marks are missing

if (answer_1 == "Flat"):
Reply
#4
Oh, I overlooked that.
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
  Winning/Losing Message Error in Text based Game kdr87 2 145 Dec-14-2020, 12:25 AM
Last Post: bowlofred
  Pyspark SQL Error - mismatched input 'FROM' expecting <EOF> Ariean 3 422 Nov-20-2020, 03:49 PM
Last Post: Ariean
  EOF error while taking input ShishirModi 1 325 Sep-27-2020, 11:28 AM
Last Post: jefsummers
  Don't understand error message Milfredo 2 324 Aug-24-2020, 05:00 PM
Last Post: Milfredo
  Input Error Dream 2 512 Jul-12-2020, 05:41 PM
Last Post: bowlofred
  what to do about this error message deric23 0 425 May-15-2020, 02:49 PM
Last Post: deric23
  Getting an error while using input function dcsethia 5 486 May-11-2020, 04:59 PM
Last Post: buran
  pip error message Marijn 1 423 Apr-21-2020, 12:05 PM
Last Post: snippsat
  Inserting input into Word doc bookmark shappaeye 2 504 Apr-21-2020, 08:12 AM
Last Post: shappaeye
  Adding second message to simple loop error PythonGainz 2 522 Apr-06-2020, 11:55 AM
Last Post: PythonGainz

Forum Jump:

User Panel Messages

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