Python menghapus dua indeks pertama
l = [1, 2, 3, 4, 5]
del l[:3] # Here 3 specifies the number of items to be deleted.
Worried Wombat
l = [1, 2, 3, 4, 5]
del l[:3] # Here 3 specifies the number of items to be deleted.
my_array=np.arange(10)
my_array[1:]
list = [1,2,3]
print(list[1:3]) # output is [2,3]
>>> l = ['a', 'b', 'c', 'd']
>>> l.pop(0)
'a'
>>> l
['b', 'c', 'd']
>>>
[a.pop(0) for i in range (10)]
# Python3 code to demonstrate
# removing front element
# using pop(0)
# initializing list
test_list = [1, 4, 3, 6, 7]
# Printing original list
print ("Original list is : " + str(test_list))
# using pop(0) to
# perform removal
test_list.pop(0)
# Printing modified list
print ("Modified list is : " + str(test_list))