Exercise 1
Write a python algorithm to display all elements of a given list in two different ways
Solution
1 2 3 4 5 6 7 8 9 10 11 12 13 |
# define a python list L = ["laptop", "ipad", "iphone", "tablet", "printer"] # first method print("\nfirst method\n-------------") for x in L: print(x) # second method print("\nsecond method\n-------------") n = len(L) for i in range(0, n): print(L[i]) |
Younes Derfoufi
CRMEF OUJDA
1 thought on “Solution Exercise 1: python algorithm that displays all elements of a list”