Python_Institute
PCEP-30-02 · Question #320
You are developing a Python application for an online product distribution company. You need the program to iterate through a list of products and escape when a target product ID is found…
The correct answer is D. 1 | while; 2 | break. See the full explanation below for the reasoning.
Question
You are developing a Python application for an online product distribution company. You need the program to iterate through a list of products and escape when a target product ID is found.
productIdList = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
index = 0
??? index < 10:
print(productIdList[index])
if productIdList[index] == 6:
???
else:
index += 1
What would you insert instead of ??? and ??? ?
Options
- A1 | if; 2 | break
- B1 | break; 2 | while
- C1 | for; 2 | break
- D1 | while; 2 | break
- E1 | while; 2 | for
- F1 | for; 2 | while
How the community answered
(42 responses)- A10% (4)
- B2% (1)
- C5% (2)
- D81% (34)
- E2% (1)
Community Discussion
No community discussion yet for this question.