RE: Another Python Indentation Problem

  • From: "Ken Perry" <whistler@xxxxxxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Thu, 9 Jun 2011 09:01:39 -0400

Actually it would work if you actually ran anything.  You just defined the
function.  If you add 

 

Gold_room()

 

At the end of your file it will run your function.  

 

Ken

 

From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Harmony Neil
Sent: Thursday, June 09, 2011 8:53 AM
To: programmingblind@xxxxxxxxxxxxx
Subject: RE: Another Python Indentation Problem

 

I've changed the bitd that say dead so they say print. I just tried running
the file again and it decides to do . nothing. The annoying thing is, it
doesn't show that there are any errors with the file either.

 

 

From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Nathaniel
Schmidt
Sent: 09 June 2011 11:07
To: programmingblind@xxxxxxxxxxxxx
Subject: RE: Another Python Indentation Problem

 

Hi,

 

Made a few quick changes to attached file, they are outlined below:

 

.         "exits" does not exist, I would say that was a typo so I changed
it to "exit."

.         As stated on the list a little earlier, there is no death ()
function defined, but I'm assuming you will create that later?

.         What was wrong with your indentation was: You cannot define a
function, use 4 space indent inside the namespace and then use another two
spaces inside an if statement, you have to use 4 again.  E.G.:

# The following does not work

 

def func ():

    if statement:

      print "This failed!"

 

# This should work:

 

def func ():

    if statement:

        print "This had better work!"

 

Hope this helps,

 

Nathaniel

 

From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Harmony Neil
Sent: Thursday, 9 June 2011 7:02 PM
To: programmingblind@xxxxxxxxxxxxx
Subject: Another Python Indentation Problem

 

Sorry to bother people on the list again. OK, I've started making a mini
text adventure thing and ran it through the command line as usual. I fixed
an error that I really should have spotted anyway (a missing quotation
mark), but it now says unexpected indentation on line 12. This is part of an
if . else statement and is at the same indentation as the if line a couple
of lines above. I changed it anyway to see if it would make a difference and
as I expected, it said invalid sintax at line 12, so I put it back to the
way it was in the first place to see if anyone else has any suggestions?

I hate indentation at times .

Attached is the file game.py

If anyone had any suggestions, feel free to reply here or offlist.

Thanks,

Harmony.

 

Other related posts: