list[s] is a string. Why doesn\'t this work?
The following error appears:
TypeError: list indices must be integers, not str
it should be:
for s in my_list: # here s is element of list not index of list
t = (s, 1)
map_list.append(t)
i think you want:
for i,s in enumerate(my_list): # here i is the index and s is the respective element
t = (s, i)
map_list.append(t)
enumerate give index and element
Note: using list as variable name is bad practice. its built in function