Monday, January 8, 2018

python list append, pop, unshift, shift, deque object insert appendleft clear copy extendleft

from collections import deque
a = [1,2,3,4,5]
a.append(6)
print a
print a.pop()
#['a'] = 'b'
a = ([10] + a + [11]) # Unshift / Push
print a
a = a[:6] # Shift / UnPush
print a, ';;;;;;;;;'
print a.pop(5)
del a[:3]
print a
print deque(a).popleft()



result::::::::::::::::::::::::::
PS D:\Projects\Python.Projects\maths> python main.py
[1, 2, 3, 4, 5, 6]
6 [10, 1, 2, 3, 4, 5, 11] [10, 1, 2, 3, 4, 5] ;;;;;;;;;
5
[3, 4] 3 PS D:\Projects\Python.Projects\maths>

No comments: