How to remove deque elements from the start in Python

1 Answer

0 votes
import collections
  
d = collections.deque('python')    

print(d)

print(d.popleft(), end='')
print(d.popleft(), end='')
print(d.popleft(), end='')

print()

print(d)



'''
run:
 
deque(['p', 'y', 't', 'h', 'o', 'n'])
pyt
deque(['h', 'o', 'n'])

'''

 



answered May 6, 2019 by avibootz

Related questions

1 answer 189 views
2 answers 237 views
1 answer 151 views
2 answers 206 views
1 answer 172 views
...