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
  Error message about iid from RandomizedSearchCV Visiting 2 932 Aug-17-2023, 07:53 PM
Last Post: Visiting
  Another Error message. the_jl_zone 2 942 Mar-06-2023, 10:23 PM
Last Post: the_jl_zone
  Error in Using INPUT statement gunwaba 1 2,014 Jul-03-2022, 10:22 PM
Last Post: deanhystad
  Mysql error message: Lost connection to MySQL server during query tomtom 6 15,670 Feb-09-2022, 09:55 AM
Last Post: ibreeden
  understanding error message krlosbatist 1 1,854 Oct-24-2021, 08:34 PM
Last Post: Gribouillis
Star I'm getting syntax error while using input function in def. yecktmpmbyrv 1 1,931 Oct-06-2021, 09:39 AM
Last Post: menator01
  Error message pybits 1 35,864 May-29-2021, 10:26 AM
Last Post: snippsat
  f-string error message not understood Skaperen 4 3,267 Mar-16-2021, 07:59 PM
Last Post: Skaperen
  Overwhelmed with error message using pandas drop() EmmaRaponi 1 2,300 Feb-18-2021, 07:31 PM
Last Post: buran
  Winning/Losing Message Error in Text based Game kdr87 2 2,926 Dec-14-2020, 12:25 AM
Last Post: bowlofred

Forum Jump:

User Panel Messages

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