Step 1: Define the list
This creates a list with 4 elements:
-
Index 0 → "a"
-
Index 1 → "b"
-
Index 2 → "c"
-
Index 3 → "d"
Step 2: The loop
This means i will take on the values 0 and 1.
Step 3: Accessing list elements
-
When i = 0:
i*2 = 0, so letters[0] → "a"
→ prints a -
When i = 1:
i*2 = 2, so letters[2] → "c"
→ prints c
✅ Final Output:


0 Comments:
Post a Comment