Python, convert an integer into an index?
Anssi Saari
as at sci.fi
Wed Sep 23 05:01:58 EDT 2015
Dennis Lee Bieber <wlfraed at ix.netcom.com> writes:
> On Wed, 23 Sep 2015 00:21:22 +0200, Laura Creighton <lac at openend.se>
> declaimed the following:
>
>
>>
>>You need to convert your results into a string first.
>>
>>result_int=1234523
>>result_list=[]
>>
>>for digit in str(result_int):
>> result_list.append(int(digit))
>>
>
> Rather wordy... <G>
>
>>>> [int(i) for i in str(1234523)]
> [1, 2, 3, 4, 5, 2, 3]
I'm suprised. Why not just:
list(str(results))
In other words, is there something else the list constructor should do
with a string other than convert it to a list?
More information about the Python-list
mailing list