Say I have a list of 5 string integers ['2', '2', '4','3'] and now I want to add the number of '2's to a list where the second element represents a count of how many '2's have occurred. How can I do this?
This is what I tried so far:
def rankbikelist(list):
list_only_rank = [] * 5
count = [] * 13
rank = '123456789'
for i in range(len(list)):
list_only_rank += list[i][0]
for j in range(12):
count[j] = list_only_rank.count(rank[j])
return count
it gives me this error: list assignment index out of range