2
I need to make a Python script that takes a string and returns the sum of the letters of that string in a list of tuples, as follows: Example:
banana -----> [('b', 1), ('a', 3), ('n', 2)]
My show is like this:
for n in txt:
c = txt.count(n)
if n != ' ':
if n not in lista_txt:
tupla = n, c
lista_txt.append(tupla)
But it returns the sum of each letter more than once:
[('b', 1), ('a', 3), ('n', 2), ('a', 3), ('n', 2), ('a', 3)]
How can I fix this?