A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2001-April/087846.html below:

Conditional operator in Python?

Conditional operator in Python?Joshua Marshall jmarshal at mathworks.com
Wed Apr 4 15:39:00 EDT 2001
Steven D. Majewski <sdm7g at virginia.edu> wrote:

>>>> def Number( *args ):
> ...     t = 0
> ...     for x in args:
> ...             t = t * 1000L
> ...             assert 0 <= x < 1000, 'Out of range' 
> ...             t = t + x
> ...     return t
> ... 
>>>> Number( 1,000,000 )
> 1000000
>>>> Number( 1,234,567)
> 1234567
>>>> Number( 1,200,300,400,500 )
> 1200300400500L
>>>> Number( 1,200,300,400,500.25 )
> 1200300400500.25

> Of course, you can also have confusing things like:

>>>> Number( 1,2,3 )
> 1002003

Be careful with this--octal notation (numbers beginning with 0) will
break it.

More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4