Computer Science, asked by CuTeBaChHi, 1 month ago

Write a function LShift(Arr,n) in Python, which accepts a list Arr of numbers and n is a numeric value by which all elements of ?

Dont spam in this answer plz ❤

Answers

Answered by rupalijadhav19061986
1

Answer:

def Lshift(Arr, n): temp = [] n = n-1 while n >= 0: a = Arr[n] temp.append(a) Arr.pop(n) n = n-1 |= len(temp) for i in range(-1, -1-1, -1): Arr.append(temp[i) print("Arr =", Arr) Arr = 0 while True: inp = int(input("enter the number ")) Arr.append(inp) cont = input("Do you want to enter more numbers [Y/N]") if cont in ["N", "n", "No", "no"]: break print(Arr) n = int(input("enter a numeric value") Lshift(Arr, n)

Answered by WonderfulSoul
18

Let's Do that :

#program to shift elements in a list def LShift(Arr,n):

def LShift(Arr,n):

L=len(Arr)

for x in range(0,n):

y=Arr[0]

for i in range(0,L-1):

Arr[i]=Arr[i+1]

Arr[L-1]=y

print(Arr)

#main

Arr=[10,20,30,40,12,11]

LShift(Arr,2)

Another information :

Python is an interpreted high-level general-purpose programming language. Python's design philosophy emphasizes co_de readability with its notable use of significant indentation.

Attachments:
Similar questions