How to rotate deque left by N in Python

1 Answer

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

print(q) 

N = -3
q.rotate(N) 

print(q) 



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

 



answered Jul 21, 2020 by avibootz

Related questions

1 answer 169 views
169 views asked Jul 21, 2020 by avibootz
1 answer 164 views
1 answer 102 views
102 views asked Nov 28, 2023 by avibootz
1 answer 121 views
2 answers 195 views
...