Step-by-Step Explanation
1️⃣ Lists Creation
a contains: 1, 2, 3
b contains: 10, 20, 30
2️⃣ zip(a, b)
zip(a, b)This pairs elements from both lists:
3️⃣ Loop Execution
for i, j in zip(a, b):i gets values from list a
j gets values from list b
| Iteration | i | j |
|---|---|---|
| 1st | 1 | 10 |
| 2nd | 2 | 20 |
| 3rd | 3 | 30 |
4️⃣ Inside Loop
i = i + 100-
This changes only the loop variable i,
-
✅ It does NOT change the original list a
Example:
-
1 → becomes 101
-
2 → becomes 102
-
3 → becomes 103
But this updated i is never printed or used further.
5️⃣ Print Statement
print(j)-
Only j is printed
j comes from list b
So it prints:
✅ Final Output
🔥 Key Learning Points
✅ Changing i does not modify list a
✅ zip() pairs values but does not link memory
✅ Only j is printed, so i + 100 has no visible effect


0 Comments:
Post a Comment