converting tuple to a list

Justin Sheehy dworkin at ccs.neu.edu
Wed Jan 12 10:48:02 EST 2000


Anders M Eriksson <anders.eriksson at morateknikutveckling.se> writes:

> Is this the 'best' way to convert a tuple to a list?
> 
> t = (1,2,3,4,5)
> l = []
> 
> for i in range(len(t)):
> 	l.append(t[i])

No, I would suggest something more like:

t = (1,2,3,4,5) 
l = list(t)

-Justin

 




More information about the Python-list mailing list