+ 2
Python del, why?
fx=[4, 5, 6, 7, 8, 10, 12, 15, 20, 25] del fx[::6] print(fx) # why the answer is [5,6,7,8,10,15,20,25]
2 Respostas
+ 7
Let's see what you are telling your program to do:-
fx=[4, 5, 6, 7, 8, 10, 12, 15, 20, 25]
#here you told it to make a list as follows
del fx[::6]
'''now you want it to delete items STARTING from 0 index and the skip 6 values and then delete one item and so on
So the program will delete values at index 0 and 6 that are values 4 and 12'''
print(fx)
#print the resultant list
So the answer is [5,6,7,8,10,15,20,25]
+ 3
Wonderful, make sense, thank you Arsenic!