Jan Danielsson: > newlist = [ None ] * len(mylist) > for i in range(len(mylist)): > newlist.append(int(e[0]))
Note that this appends after the Nones, not over them. And note that here the name 'e' is undefined. The most used idiom for that is: newlist = [int(e[0]) for e in mylist] Or better lazily if you want to create a set, avoiding the list creation: newlist = set(int(e[0]) for e in mylist) Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list