On Fri, Jul 13, 2012 at 11:46 PM, Santosh Kumar <sntshkm...@gmail.com>wrote:

> Like in my script:
>
> #!/usr/bin/env python
> #-*- coding:utf-8 -*-
>
> print "You will be prompted to enter your height in feet and inches."
> height_in_feet = input("How much feet are you long: ")
> remaining_inches = input("How much inches remained? ")
>
> inches_in_feet = height_in_feet * 12
>
> total_height_in_inches = inches_in_feet + remaining_inches
>
> print "You are %d inches long." % total_height_in_inches
>
>
> Here I want something like:
> Enter you height in format like 5' 10"
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>

Here's one way:

FEET_SEPERATOR = "'"
height = raw_input("Enter your height (ie: 6'1)")
heightSplit = height.split(FEET_SEPERATOR)
heightFeet = int(heightSplit[0])
heightInches = int(heightSplit[1])
inchesFromFeet = heightFeet*12
totalInches = inchesFromFeet + heightInches
print 'You are {0} inches'.format(totalInches)
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to