Jump to content

Please Help

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
15 replies to this topic

#1
Prestidigitator

Prestidigitator

    Newbie

  • Members
  • PipPip
  • 14 posts
I can not figure out what is wrong with this code. IDLE says that there is inconsistent indentation. Can anyone help?
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: [COLOR="GREEN"]It shows the problem in this line.[/COLOR]
                        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 ""

Edited by Prestidigitator, 26 February 2009 - 05:16 PM.
add code tags (the # button)


#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
The else for the indicated if is indented an extra space.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
Prestidigitator

Prestidigitator

    Newbie

  • Members
  • PipPip
  • 14 posts
That must have happened when I posted it, it looks okay in IDLE.

#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
What font are you using in IDLE?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#5
Prestidigitator

Prestidigitator

    Newbie

  • Members
  • PipPip
  • 14 posts
I don't know how to tell what font I am using.

#6
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
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

#7
Prestidigitator

Prestidigitator

    Newbie

  • Members
  • PipPip
  • 14 posts
I put it into notepad and redid the spacing, and it works now.
Thanks for your help.

#8
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
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

#9
Prestidigitator

Prestidigitator

    Newbie

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

#10
Brandon W

Brandon W

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 4,828 posts
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!


#11
Prestidigitator

Prestidigitator

    Newbie

  • Members
  • PipPip
  • 14 posts
I am planning on learning C++ or D next.

#12
Brandon W

Brandon W

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 4,828 posts
Why would like to learn D?
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!