Closed Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: Please Help

  1. #1
    Join Date
    Feb 2009
    Posts
    14
    Rep Power
    0

    Please Help

    I can not figure out what is wrong with this code. IDLE says that there is inconsistent indentation. Can anyone help?
    Code:
    def menu(list, question):
    	for entry in list:
    		print 1 + list.index(entry),
    		print ") " + entry
    		
    	return input(question) - 1
    items = ["Curvy Alien Vase,""The Mona Lisa","Aristotles Bookshelf","The Worlds Largest Pair of Boots","The Mystical Door of Incredibly Awesome Mystical Magic"]
    keylocation = 2
    
    keyfound = 0
    
    loop = 1
    
    print "Last night you went to sleep in the comfort of your Incredibly Comfortable Bed of Sleep and Resting,"
    
    print "But while you slept" 
    print "Maniacal Plotting Evil Little Tiny Elf-Creatures of Uncertain Doom and Despair" 
    print "drug you out and locked you in a small room with no windows and only one way out,"
    print len(items), "things:"
    for x in items:
    	print x
    print "The Worlds Largest Pair of Boots","The Mystical Door of Incredibly Awesome Mystical Magic"
    print "The Mystical Door of Incredibly Awesome Mystical Magic is locked,"
    print "I wonder if there is a key anywhere."
    while loop == 1:
    	choice = menu(items,"Wha' yoo wanna look a'? ")
    	if choice == 0:
                   if choice == keylocation: It shows the problem in this line.
                            print "You found a small key in the Curvy Alien Vase"
    
                            print ""
                            keyfound = 1
                   else:
                            print "You found nothing in the Curvey Alien Vase."
                            print ""
            elif choice == 1:
                    if choice == keylocation:
                            print "You found a small key behind The Mona Lisa."
                            print ""
    			
                            keyfound = 1
                    else:
                            print "You found nothing behind The Mona Lisa."
                            print ""
            elif choice == 2:
                    if choice == keylocation:
                            print "You found a small key in Aristotles Bookshelf."
                            print ""
                            keyfound = 1
                    else:
                            print ""
            elif choice == 3:
                    if choice == keylocation:
                            print "You found a small key in The Worlds Largest Pair of Boots"
                            print ""
                            keyfound = 1
                    else:
                            print "You found nothing in The Worlds Largest Pair of Boots"
                            print ""
    			
            elif choice == 4:
                    if keyfound == 1:
                            loop = 0
                            print "You put the key in, turn it, and hundreds of Maniacal Plotting Evil Little Tiny Elf-Creatures of Uncertain Doom and Despair swarm out and devour your flesh," 
                            print "jump on your bloody carcass until it turns to dust" 
                            print "then calmly walk out of the Mystical Door of Incredibly Awesome Door of Mystical Magic," 
                            print "then lock it and walk away as if nothing had happened."
    			
                            print ""
                    else:
                            print "Hundreds of Maniacal Plotting Evil Little Tiny Elf-Creatures of Uncertain Doom and Despair"
                            print "spit on your eyes until you lose conciousness"
                            print ""
    Last edited by Prestidigitator; 02-26-2009 at 05:16 PM. Reason: add code tags (the # button)

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Jul 2006
    Posts
    16,486
    Blog Entries
    75
    Rep Power
    143

    Re: Please Help

    The else for the indicated if is indented an extra space.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  4. #3
    Join Date
    Feb 2009
    Posts
    14
    Rep Power
    0

    Re: Please Help

    That must have happened when I posted it, it looks okay in IDLE.

  5. #4
    Join Date
    Jul 2006
    Posts
    16,486
    Blog Entries
    75
    Rep Power
    143

    Re: Please Help

    What font are you using in IDLE?
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  6. #5
    Join Date
    Feb 2009
    Posts
    14
    Rep Power
    0

    Re: Please Help

    I don't know how to tell what font I am using.

  7. #6
    Join Date
    Jul 2006
    Posts
    16,486
    Blog Entries
    75
    Rep Power
    143

    Re: Please Help

    The code in the window above is in a monospace font. If you open your code in some other editor, and change the font to something like courier, you may be able to find the problem.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  8. #7
    Join Date
    Feb 2009
    Posts
    14
    Rep Power
    0

    Re: Please Help

    I put it into notepad and redid the spacing, and it works now.
    Thanks for your help.

  9. #8
    Join Date
    Jul 2006
    Posts
    16,486
    Blog Entries
    75
    Rep Power
    143

    Re: Please Help

    I'm glad it worked for you

    How are you liking Python so far?
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  10. #9
    Join Date
    Feb 2009
    Posts
    14
    Rep Power
    0

    Re: Please Help

    I'm surprised at how easy it is. I was expecting programming (with all languages) to be a lot harder.

  11. #10
    Join Date
    Sep 2008
    Location
    Australia
    Posts
    4,834
    Blog Entries
    10
    Rep Power
    51

    Re: Please Help

    Programming is not too hard once you get the hang of it. I remember Jordan saying once, when he has learned one language, it becomes easier to learn another.

    Python has pretty simple syntax so it would be great for a starter like you Do you plan to go further than Python one day?
    jQuery Selectors Tutorial - jQuery Striped Table tutorial - jQuery Events - jQuery Validation
    Sorry if I don't post as often as I did, I'll try to get here as much as possible! I'm working my bum off to get this scholarship and other stuff!

Closed Thread
Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts