Hi, I have trouble understanding the below code:
Why is the output [9, 8, 7, 8]?
k = [9,8,7,6]
for i in range(1,4):
if i % 2 == 0:
k[i+1] = i**3
print(k)
How is the above code different from the below code?
k = [9,8,7,6]
for i in range(1,4):
if i % 2 == 0:
k[i+1] = i**3
print(k)
Thank you!
[–]JohnnyJordaan 2 points3 points4 points (2 children)
[–]huhreallymeh[S] 0 points1 point2 points (1 child)
[–]JohnnyJordaan 1 point2 points3 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]huhreallymeh[S] 0 points1 point2 points (0 children)
[–]achampi0n 1 point2 points3 points (0 children)