1. convertion between list and tuple
tuple(<list>) list(<tuple>)
2. ('aa',) means a tuple containing only one element 'aa'
('aa') means a tuple containing two elemetns: 'a' and 'a'
so, ('aa') != ('aa',), you can convert them to list to check the difference
In [17]: list(('aa')) Out[17]: ['a', 'a'] In [18]: list(('aa',)) Out[18]: ['aa']
3. iterate a list or tuple
for e in mylist:
print(e)
length = len(mylist)
for i in range(length)
print(mylist[i])
for
(i,val)
in
enumerate
(
list
):
print
(i,
val)