How to remove the first occurrence of element in deque with Python

1 Answer

0 votes
import collections 
  
q = collections.deque([1, 18, '27', 2, 'python', 18, 19, 18, 18]) 

print(q) 

q.remove(18)

print(q) 



   
'''
run:
    
deque([1, 18, '27', 2, 'python', 18, 19, 18, 18])
deque([1, '27', 2, 'python', 18, 19, 18, 18])
 
'''

 



answered Jul 21, 2020 by avibootz

Related questions

...