this one really got me good i thought its [life, everything, 42, universe]
@b088mohdzaid5 Жыл бұрын
I got it when the loops comes at the end and compare the IF condition If 0 == 0; (note that first “zero” is in our list) then it’s becomes true and then L[0] = “universe” applies, thus position at 0 is changed This is tricky cause in any other prog language we loop through indices like 1,2,3,4… but in python they loop through list elements.
@chandlerzhu97355 жыл бұрын
tricky, it uses "0" as an index
@shahanahmed9524 жыл бұрын
So, Basically at Index thing= 3, it replaced the value at Index '0' not '3'
@nishanthmaran46672 жыл бұрын
It's shows the output as ['life','everything',42,0] Anyone please help me
@akbarrauf27417 жыл бұрын
thank you ,mit
@sohrabgh54485 жыл бұрын
we changed list.. why iteration does not stop?
@klubotics4 жыл бұрын
sohrab gh We did not have a break statement or reach some sort of stop condition after the line which mutates the list. Thus, the for loop continues until there are no more elements.
@brainstormingsharing13093 жыл бұрын
👍👍👍👍👍
@rachel_rexxx2 жыл бұрын
This problem requires noticeable deeper thought
@날개달린_양 Жыл бұрын
tysm
@abdulazizmukhamedov35533 жыл бұрын
L = ["life", "answer", 42, 0] for thing in L: if thing == 0: L[thing] = "universe" elif thing == 42: L[1] == "everything" print(L) I got this answer: ['universe', 'answer', 42, 0]
@muntaface3 жыл бұрын
You have a L[1] == 'everything, it should be L[1] = 'everything' (single '=' )