Python Forum
name "MyVariable" can be undefined
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
name "MyVariable" can be undefined
#1
Hello, I am a new coder and am trying to make a short choose-your-own-adventure game in an attempt to learn the basics of python. no matter what i do, though, one of my variables keeps getting read as undefined. i am unsure on how to appropriately fix the issue, and i will paste a segment of the code here for review.
    while 4 < 5:
        while 5 > 6:
            setval = input("What Do you do?")
            if setval == 8:
                COURSEGET = 1
                print("This room is full of star charts and maps")
                print("With all of these, you can path your way home!")
                print("You return to the main room.")
                if setval == 7:
                    if COURSEGET == 1:
                        print("You punch in the code for home, and are saved from dying alone in space.")
                        COURSESET = "true"
                    else:
                        print("The Console is awaiting a flight course. You return to the main room")
                    if setval == 9:
                        if COURSESET == "true":
                            print("The Engine room is warm, and humming with energy.")
                            print("The start button on the engine is glowing red, but you haven't set a course yet.")
                            print("Better not press it. You return to the main room")
                        else:
                            print("You Press the start button on the engines, and the ship Rockets off.")
                            print("You safely arrive back in federal space, and are welcomed home.")
                            print("This'll make a helluva story for the kids.")
                            MAINVAL = "Extra"
                            if MAINVAL == "Extra":
                                print("Thank you for playing, please share this little adventure game of mine!")
                                break
Reply
#2
Something is really wrong with this code. The while 4 < 5 will loop indefinitely because the condition is always True, and everything under the while 5 > 6 will never be executed because the condition is always False.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  undefined function error JonWayn 5 1,461 Sep-11-2022, 03:38 AM
Last Post: JonWayn
  Undefined Led_Zeppelin 4 1,434 Aug-02-2022, 11:57 AM
Last Post: buran
  ImportError: /home/pybind11_example.cpython-37m-x86_64-linux-gnu.so: undefined symbol chaitra 2 5,132 Feb-03-2021, 05:14 AM
Last Post: chaitra
  function error: undefined variable Atlantic_3000 3 6,970 Apr-12-2020, 02:53 AM
Last Post: bowlofred
  name undefined Coding Error Ewilliam51 2 2,154 Feb-06-2020, 12:19 AM
Last Post: Ewilliam51
  Timestamp is undefined ErnestTBass 7 7,973 Feb-16-2019, 08:27 PM
Last Post: snippsat
  python charmap codec can't decode byte X in position Y character maps to < undefined> owais 9 39,173 Apr-28-2018, 10:52 PM
Last Post: abadawi
  Python code with serial port and global undefined marciokoko 13 14,525 Jan-17-2017, 06:14 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

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