[Tutor] (no subject)

Pravya Reddy pravyareddy at gmail.com
Mon Feb 11 16:58:55 CET 2013


Can you please help me with the code.

#!/usr/bin/env python
"""
inchtocm.py

"""

def Inchtocm(inches):
    """Returns 2.54 * inches"""
    return (2.54 * float(inches_number1))

inches = None
while True:
    try:
        inches_number1 = input(input("How many inches you want to convert:
"))
        inches = float(inches_number1)
        print ("You got", Inchtocm(inches), "cm.")
        print ("You converted", inches, "inches to cm.")
        break
    except ValueError:
        print ("This is not a number!")

The code is incomplete and i am not getting a proper output:

How many inches you want to convert: 455
455
This is not a number!
How many inches you want to convert:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130211/ffbc9f09/attachment.html>


More information about the Tutor mailing list