Hapus array item pertama di Python
list = [1,2,3]
print(list[1:3]) # output is [2,3]
Loki_py
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)]
del a_list[0]
# 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))