How to rotate deque right 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([18, 19, 18, 1, 18, '27', 2, 'python'])
 
'''

 



answered Jul 21, 2020 by avibootz

Related questions

1 answer 152 views
152 views asked Jul 21, 2020 by avibootz
1 answer 164 views
1 answer 106 views
2 answers 129 views
...