1 Replies - 499 Views - Last Post: 13 November 2015 - 12:59 AM Rate Topic: -----

#1 albert003   User is offline

  • D.I.C Addict

Reputation: 39
  • View blog
  • Posts: 993
  • Joined: 15-December 14

Stuck on lesson #43 learn python the hard way

Posted 13 November 2015 - 12:13 AM

I'm trying to make the game Zed Shaw wants me to make in lesson #43 ("Gothons from Planet Percal #25") and I am stuck.In the lesson he wants me to make it similar to Zork or Adventure type game. I want to make the game interactive without having the player having to key in anything aside from the choices to play the game. I can get as far as having the player key in their name but after words the program won't go to the "start_scene" function. I don't understand why it says I don't have it defined if in the start_scene function I have it defined.I know how to loop between functions when I'm not using oop but I can't figure out how to make it work using oop. Below is the error and below that is my program so far. This is the error message I keep getting. Any and all suggestions are appreciated.

Traceback (most recent call last):
File "C:\Python27\ex043Map.py", line 15, in <module>
p1=Map("","")
File "C:\Python27\ex043Map.py", line 8, in __init__
print"Hello {}. Select one of the options".format(main_Menu)
NameError: global name 'main_Menu' is not defined



class Map(object):
    mainMenu=['start game','quit']
    def __init__(self,start_scene,name):
        self.start_scene=start_scene
        self.name=name
        print"Welcome to my game please enter your name"
        name=(raw_input())
        print"Hello {}. Select one of the options".format(main_Menu)
    def start_scene(self,mainMenu):
        main_Menu=['start game','quit']
    
        


p1=Map("","")
p1.start_scene



Is This A Good Question/Topic? 0
  • +

Replies To: Stuck on lesson #43 learn python the hard way

#2 andrewsw   User is offline

  • no more Mr Potato Head
  • member icon

Reputation: 6957
  • View blog
  • Posts: 28,696
  • Joined: 12-December 12

Re: Stuck on lesson #43 learn python the hard way

Posted 13 November 2015 - 12:59 AM

Duplicate closed.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1