[Tutor] Just a Python formatting question

Ertl, John john.ertl at fnmoc.navy.mil
Wed Jun 8 19:09:32 CEST 2005


Kristiano,

It is sometimes hard to tell the indentions in an email but it looks like
your last line

 print "Just right"

has a space in front of it.  Python does not know what logical block the
indented part belongs to.

John Ertl 

-----Original Message-----
From: Kristiano Ang [mailto:kristiano7 at gmail.com]
Sent: Wednesday, June 08, 2005 09:49
To: tutor at python.org
Subject: [Tutor] Just a Python formatting question

Hey guys,
  I'm pretty new to Python (using Mac Python 2.4.1) and have a
question with formatting that I hope you can help me with.

  Sometimes, when I write code with Python (copied off tuts.), I get
error messages and highlights of the word "else". Take for example:

#plays the guessing game higher or lower

#originally written by Josh Cogliati, improved by Quique and copied by
Kristiano Ang

number=78
guess=0

while guess != number:
    guess=input ("Guess a number:")
    if guess > number:
        print "Too High"
    elif guess < number:
            print "Too low"

 print "Just right"


I just can't get it to run and I get some indentation error.

  I'm pretty new to this so I'm sorry if this question(s) sound(s)
amateurish. Do help.

Thanks.
-Kristiano Ang
_______________________________________________
Tutor maillist  -  Tutor at python.org
http://mail.python.org/mailman/listinfo/tutor


More information about the Tutor mailing list