Getting a number out of a string

Steven D'Aprano steve at REMOVETHIScyber.com.au
Tue Sep 27 19:43:49 EDT 2005


On Tue, 27 Sep 2005 20:28:53 +0000, Claudio Grondi wrote:

> what about:
>>>> lst = [digit for digit in '06897']
>>>> lst
> ['0', '6', '8', '9', '7']

No need to use a list comprehension when this works just as well:

py> list('06897')
['0', '6', '8', '9', '7']

-- 
Steven.




More information about the Python-list mailing list