[Tutor] 2 Very basic queries

Saad Bashir bashir.saad at gmail.com
Tue Mar 25 20:21:49 CET 2014


Hi everyone!

I am a novice programmer and actually learning to program in Python. I have
two issues that I am embarrassed to present as they seem to be extremely
basic.

1.  But encouraged by the site to ask event the most basic questions on
this forum, here goes:

 I am using the book:

Practical Programming: an introduction to computer science using Python 3.

As per its instructions I am using the IDLE environment (Python shell) of
Python [3.2.3 MSC v.1500 64 bit AMD64].  I have been going through the book
without any problems but have become stuck at the following stage:

When using "if" and "elif" statement I get two types of error messages:

1. Practicing the code as given in the book:

    >>> ph = float(input('Enter the pH level: '))
Enter the pH level: 8.5
>>> if ph < 7.0:
...       print(ph, "is acidic.")
...        elif ph > 7.0:
...         print(ph, "is basic.")

When I write this in the Python shell, as soon as I hit return after "elif
ph > 7.0:"
I get an error message highlighting "elif" and saying syntax error.

Or if I try the indentation as follows with elif aligned if above I get the
message below:

>>> ph = float(input('Enter the pH level: '))
Enter the pH level: 8.5
>>> if ph < 7.0:
...       print(ph, "is acidic.")
...    elif ph > 7.0:
...     print(ph, "is basic.")

"SyntaxError: : unindent does not match any outer indentation level.

I have tried everything I can think of but to no avail. Please help.


2. Another problem is that the Python shell is allowing me to copy/paste
any code at all.  Is there something I am not doing right?

Apologies in advance for wasting everyone's time but will be very grateful
if I am helped.

Saad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140325/7f07edd0/attachment-0001.html>


More information about the Tutor mailing list