Day 14 -  Part E

Run Settings
LanguagePython
Language Version
Run Command
l=[1,2,3,4,5,6,7,8,9] print(l[1:15:3]) print(l[-1:-4:-2]) l=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16] # 0,1,2,3,4,5,6,7,8, 9,10,11,12,13,14,15 print(l[1:22:3]) print(l[-3:-12:-3]) #[16-3 i.e. 13], [i.e.5] result [14,11,8] l=[1,3,5,7,9,11,13,15,16, 17] print(l[-3:-12:-3]) # print the list from position -3, and then move left 3 and the move left 3 again print(l[-3:-12: 3]) # it is be empty when step is positive l=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16] print(l[3:-5:4]) print(l[4:-4:-4]) # it will be empty list or point 4 backward 4 print(l[14:-14:-4]) # 14 is -2 and step is -4, therefore the list is available print(l[-10:14:3]) # -10 step with 3 is enough to go right therefore the list is available print(l[-14:-3: 3]) # position -14 i.e. position 2 i.e. value 3 and then move to right print(l[-13:2:-4]) print(l[-13:2:-2]) print(l[-13:0:-2]) del l[:2] # delete the list first two element print(l) l=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16] print(l) # -------------------+step # if start > len(list) => len(list) print(l[16:99:1]) #if end >len(list) => end = len(list) => until last element of the list print(l[99:99:1]) print(l[15:99:1]) # if start < 0 , start = max(0, len(list) + start) # if end < 0,end = max(0,len(list)+end) # hint: ending value must be smaller than len(list); otherwise empty list print(l[-99:1:1]) # where -99 = first position i.e.0 print(f'end = -99 : {l[:-99]} with something else print after function return') # end position < len(list) will end list print("end = -99: {0}".format(l[:-99])) # same as list 35 print("end = -99: {0} with {3} something {2} else {1}".format(l[:-99],1,2,3)) # same as list 35 and it add #more print content accoring paramteres # if start is missing or None start = 0 #if end is missing or None end = len(llist) print(l[None:12:1]) print(l[1::]) #if start > len(list) start = len(list) -1 => starting from the last element print(l[99:13:-1]) # if end > len(list); end = len(list) -1 print(l[1:99:-1]) print(l[15:99:-1]) # 15 is the last element and stop in front of last from right (i.e.-1) therefore empty list # if start < 0; start = max(-1,len(list) + start)=> start from last if # |-vs (i.e. abs value ) > len(list) => empty [] print(l[-16 :6:-1]) print(l[-3:6:-1]) # from -3 is work for within length # if end < 0; end = max(-1, len(list) + end) => endnat the beginning of the list print(l[7:-99:-1]) # the reverse order by two steps x=l[-4:-1] # print(x[::-1]) # if start is missing of None ; start = len(list) -1 => from the end of the list print(l[:5:-1]) # if end is missing or None; end = -1 - (index, not postion number)=> begining of the list print(l[2::-2]) print(l[::-1])
Editor Settings
Theme
Key bindings
Full width
Lines