Skip to content

Commit f9ad7bb

Browse files
committed
Rotate to right
1 parent 8807f87 commit f9ad7bb

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Array/Rotate_Right.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
3+
arr = list();
4+
n=int(input("Enter the number of elements you want in the array: "))
5+
6+
#print("Enter the array elements one by one:")
7+
for i in range(int(n)):
8+
print("Enter the",i+1,"element of the array: ",end='')
9+
arr.append(int(input()))
10+
11+
#Display the original array
12+
print("Array before rotation is:",arr)
13+
14+
#rotation of the array by 3 elements to right by slicing
15+
l=arr[n-3:n]
16+
del arr[n-3:n]
17+
l=l+arr
18+
print(l)

0 commit comments

Comments
 (0)