Exercise 19
Write a Python algorithm that list the strings that make up the list l = ["laptop", "iphone", "tablet"] while indicating the length of each string.
Solution
1 2 3 4 |
l = ["laptop", "iphone", "tablet", "printer", "Ipad"] # iterate through the elements of the list l for x in l: print(x, " is in list l, its length is: ", len(x)) |
Younes Derfoufi
CRMEF OUJDA
2 thoughts on “Solution Exercise 19: listing the elements of a list in python”