[Tutor] python help.. dictionary.

orbitz at ezabel.com orbitz at ezabel.com
Mon Apr 5 20:11:05 EDT 2004

Try to convert the string to a float, or iterate over teh string and see if only
digits and a . are contained in it.  Using float() to convert it to a float is
probably easiest, but you will need a try/except block to catch the exception it
will throw if it fails.
The rest of your program seems pretty standard and should be easy to figure out
if you think about it.

Hope that helps.

On Mon, 05 Apr 2004 19:06:00 -0400
"Yaj Lis" <chronolee24 at hotmail.com> wrote:

> hello .. i'm new too python.. and programming..and learning slowly...
> i'm creating a bank teller program. It has a list and dictionary.
> It askes for the user's input (raw_input) asking for an amount. If the user 
> enters letters instead of an amount it would count it as 'counterfiet'. 
> Would i have to write a for loop function? how would i compare to see if it 
> is a string or an interger?..and i can't figure out how to work it with the 
> dictionary.. like if i put in $30.25.. it would return "you have 1 $20 bill, 
> 1 ten, and 1 quarter" .. i'm so frustrated.
> here's what i have so far..
> wallet=raw_input("money in wallet ")
> for i in conterfeit(x):
> bank={}
> bank['h']=100
> bank['F']=50
> bank['T']=20
> bank['t']=10
> bank['f']=5
> bank['o']=1
> bank['q']=.25
> bank['d']=.10
> bank['p']=.01
> x=wallet
> counterfeit(x)
> I want the program to output something like this...It should report the 
> total value of the legal money as a floating point value (e.g. 123.45) and 
> the total number of counterfeit pieces received.
> Money in wallet: asdfasdf
> Contained "1" counterfiet piece(s).
> Total amount in bank $20.00
> asking for any help? thanks a lot..
> _________________________________________________________________
> Watch LIVE baseball games on your computer with MLB.TV, included with MSN 
> Premium! 
> http://join.msn.com/?page=features/mlb&pgmarket=en-us/go/onm00200439ave/direct/01/
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor

More information about the Tutor mailing list