Bird
0
0

Which of these is the correct syntax to iterate over a list nums and print each number?

easy📝 Syntax Q3 of 15
Python - For Loop
Which of these is the correct syntax to iterate over a list nums and print each number?
Afor num in nums: print(num)
Bfor num in nums: print(num)
Cfor num in nums print(num)
Dfor num nums: print(num)
Step-by-Step Solution
Solution:
  1. Step 1: Check for correct for loop syntax

    The for loop must have a colon ':' at the end of the first line.
  2. Step 2: Check indentation of the print statement

    The print statement must be indented inside the loop.
  3. Final Answer:

    for num in nums:\n print(num) -> Option A
  4. Quick Check:

    Correct syntax includes ':' and indentation [OK]
Quick Trick: Always use ':' and indent inside for loops [OK]
Common Mistakes:
MISTAKES
  • Missing colon after for statement
  • No indentation inside loop
  • Wrong for loop structure

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes