Untitled
unknown
plain_text
5 years ago
1.1 kB
5
Indexable
l = [1, 2, 3] # <---- We have created a list with 1, 2, 3
val = 10 # We created a Dummy variable val, that has 10 in it
idx = 0 # What is the main purpose of idx ?? <-- Question 1
while idx < len(l): # so while idx which is 0 right now, is less than the len of the list, do it means 1, 2, 3 making it 7 (counting the , and spaces) or 1+2+3 = 6 or how is it measuring the length ? <--- Question 2
if l[idx] == val: # I am little unsure how to speak this code part in English.... so if list l, idx element in the list is equals to val which is 10 <--- Question 3
break # than quit, break the code, break the loop.
idx += 1 # if above is not true, than idx right now is 0, than add 1 to it.
else: # And if nothing above was true, but i am confused, if While idx which is 0 is less than lenght of list l ?? If you can check my Question 2 above <---- Question 4
l.append(val) # Just add the val, which is 10 in to the list.
print(l) # print the list l now. Editor is loading...