-4

I want to print a specified element from each list until it stops, however I am not sure of what loop conditions to use.

Code

enter image description here

For example, I have printed element[0] of each list but I want it to loop until it prints all the elements.

Any help is appreciated. Thanks

Nayantara Jeyaraj
  • 2,566
  • 6
  • 32
  • 59
s.bha
  • 1
  • 1
  • 1
    Possible duplicate of [Looping over a list in Python](https://stackoverflow.com/questions/9138112/looping-over-a-list-in-python) – T.Nel Apr 04 '18 at 09:15

1 Answers1

0

The following code is, maybe, the simplest solution to print all the cats. If you want to print a single list, use only the last 2 lines after replacing "l" with your list variable.

a = ['Ginger', 'Lion', 'Persian', 'Sphynx']    
b = ['Mainecoon', 'Tiger', 'Ragdoll', 'Birman']
c = ['Lynx', 'Shorthair', 'Abyssinian', 'Scottishfold']
d = ['Ocelot', 'Jaguar', 'Chartreux', 'Korat']

lists = [a, b, c, d]
for l in lists:
    for cat in l:
        print(cat)