I was asked to solve a problem like this, but I found it a little bit difficult, as I am beginner in Python :
"Write code that uses iteration to print out the length of each element of the list stored in str_list."
str_list = ["hello", "", "goodbye", "wonderful", "I love Python"]
and I answered in a long silly way :
count = 0
for g in str_list[0] :
count = count + 1
print(count)
count = 0
for g in str_list[1]:
count = count + 1
print(count)
count = 0
for g in str_list[2]:
count = count + 1
print(count)
count = 0
for g in str_list[3]:
count = count + 1
print(count)
count = 0
for g in str_list[4]:
count = count + 1
print(count)
Please could you help me find a short summarized way to solve that problem.