LearnFrenzy
Sign in Take a free test

Loops · Predict the Output · Question 7

enumerate() with start Answer, explanation & discussion

  • Output
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
Question 7 Back to Exercise

What is the output of the following Python program?

main.py
for i, ch in enumerate("abc", 1):
    print(i, ch, end="; ")
print()
  • A 0 a; 1 b; 2 c;
  • B 1 a; 2 b; 3 c; Correct
  • C a 1; b 2; c 3;
  • D 1 abc;
Correct Answer: Option B

start=1 (here passed by position) makes the count begin at 1 instead of 0.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links