String Size Using Lists

Asked

Viewed 41 times

-1

How do I print the size of each of the strings the user types? Every time I ask to print out how many strings are inside the list and not the number of characters of each string inside

lista = []
while True:
    nome = str(input())
    if nome == 'fim' or nome == 'FIM':
        break

    lista.append(nome)


print(len(lista))``` 

1 answer

0

If you want to print the amount of letters in each string inside a list you must go through it this way:

lista = []
while True:
    nome = str(input())
    if nome == 'fim' or nome == 'FIM':
        break

    lista.append(nome)


for item in lista:
  print(len(item))

Browser other questions tagged

You are not signed in. Login or sign up in order to post.