Combining digit in a list to make an integer

Joel joel-123 at dodgeit.com
Fri Apr 1 06:50:22 EST 2005


Harlin Seritt wrote:
> If anyone has time, would you mind explaining the code that Dan
Bishop
> was so kind as to point out to me:
>
> int(''.join(num1))
>
> This worked perfectly for me, however, I'm not sure that I understand
> it very well.
>
> Thanks,
>
> Harlin Seritt

''.join(list of strings) is a python idiom for fast string
concatenation. ''.join(num1) would give "145". The function int() is
then used to convert the resulting string into an integer.




More information about the Python-list mailing list