I am trying to count each letter up without using count() or
dict().
I did write something but I am still having issues with my code.
myString = []
#countList = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
myString ="pynativepynvepynative"
countList = [len(myString)+1]
for i in range(len(myString)):
#print("Here 0")
for j in range(len(countList)):
#print("Here 1")
if i == countList[j]:
#print("Here 1.1")
countList[j+1] = (countList[j+1] + 1)
break
else:
#print("Here 2")
countList.append(myString[i])
countList.append(1)
break
print(countList)
Expected output:
['p', 3, 'y', 3, 'n', 3, 'a', 2, 't', 2, 'i', 2, 'v', 3, 'e', 3]
Actual output:
[22, 'p', 1, 'y', 1, 'n', 1, 'a', 1, 't', 1, 'i', 1, 'v', 1, 'e', 1, 'p', 1, 'y', 1, 'n', 1, 'v', 1, 'e', 1, 'p', 1, 'y', 1, 'n', 1, 'a', 1, 't', 1, 'i', 1, 'v', 1, 'e', 1]