Skip to main content

9.7) Exercise 23 - For Loop


  1. Write a program using a for loop that prints all the elements of the list one at a time.
  2. L1=[23,45,67,89,9999.99]
    

    [tippy title="Solution"]

    for a in L1:
        print a
    

    [/tippy]

  3. Write a program using nested for loops to display this nested list.
  4. L2=[[1,2,3],[4,5,6],[[7,8,9][10,11,12]]]
    

    [tippy title="Solution"]

    for sublist in L2:
        for element in sublist:
            print element
    

    [/tippy]