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)
The else for the indicated if is indented an extra space.
That must have happened when I posted it, it looks okay in IDLE.
What font are you using in IDLE?
I don't know how to tell what font I am using.
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.
I put it into notepad and redid the spacing, and it works now.
Thanks for your help.
I'm glad it worked for you
How are you liking Python so far?
I'm surprised at how easy it is. I was expecting programming (with all languages) to be a lot harder.
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 youDo 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!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks