Conditions & Loops · Question 10 · Medium

enumerate() numbers a list of names starting from 1. What line is printed?

names = ["Gita", "Hari", "Indu"]
for i, name in enumerate(names, start=1):
    if i == 2:
        print(i, name)
  1. 2 Indu
  2. 1 Hari
  3. 2 Gita
  4. 2 Hari
Answer and explanation

Answer: D. 2 Hari

Explanation: With start=1 the pairs are (1, Gita), (2, Hari), (3, Indu). The counter equals 2 for the second name, Hari.

Previous: continue is used inside a loop over range(1, 8). Which numbers are printed? · Next: zip() pairs two lists of unequal length inside a loop. What total is printed?

Practise conditions & loops

Try a fresh set of conditions & loops questions with an explanation after every answer, free and without signing up: Conditions & Loops practice. Or sit a full placement mock test.

More conditions & loops questions

More python practice

Functions & Scope · Comprehensions & Generators · Classes & Objects · Exceptions & Files · Built-ins & Standard Library · Variables, Types & Operators · Python Strings · Lists & Tuples

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge