[Tutor] Limit raw_input to hundredth decimal point

Izz ad-Din Ruhulessin izzaddin.ruhulessin at gmail.com
Fri Jul 1 12:09:46 CEST 2011


You can use a regular expression or plain simple len()

2011/7/1 Ryan Kirk <ryankirk at me.com>

> Is there a way to limit raw_input to the hundredth decimal point?
>
> For example, I'd like to allow the user to enter 5.75 but not 5.756:
>
> dollars = raw_input("Please enter a dollar amount: $")
>
> Thanks!
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110701/3a041a3c/attachment.html>


More information about the Tutor mailing list