Shifting Each List Element One Step Left or Right in Python | In Hindi

preview_player
Показать описание
Shifting Each List Element One Step Left or Right in Python In Hindi

In this video, I have explained a list program in which you have to shift all the elements of the list one step left or one step right. This is one of the most important program

Join this channel to get access to perks:

Tags Used:

python list programs
python list
python list program for board exam
important list program for board exam
python list important program
python list program example
list programming
python program to shift list element
shifting each list element one step left or right in python
important list program in python
python list programs
important list programs
codeitup
codeitup python
python codeitup
list programming

#codeitup
#list
#python
Рекомендации по теме
Комментарии
Автор

b=[5, 3, 12, 5, 14]
x=b[0]
b.remove(b[0])
b.insert(len(b), x)
print(b)

I think shortest and accurate

uyentertain
Автор

# Shifting Each List Element One Step Left or Right in List
def left():
key=a[0]
for i in range(1, size):
a[i-1]=a[i]
a[size-1]=key
print("List after changes", a)
def right():
key=a[size-1]
for i in range(size-2, -1, -1):
a[i+1]=a[i]
a[0]=key
print("List after changes", a)

# __main__

a=[]
size=int(input("Enter your size: "))
for i in range(size):
val=int(input("Enter value in a: "))
a.append(val)
print()
print("Original list is: ", a)
while True:
key=int(input("Press 1 for Left shifting of element\nPress 2 for Right shifting of element\nEnter your choice: "))
if key==1:
left()
elif key==2:
right()
else:
print("You are out of loop")
break



sir main chahta hu ke emse jb main left function ko call kru tb ye original list ko base bana kr interchange kre na ke right function call krne pr jo list aaya hai usko base bana kar

imraniqbal
Автор

Thank you so much sir,
For making us fall in love with coding 😊

diyajain
Автор

4:07 a= list(map(int, input("give numbers").split()))
This is a better way i guess

fiend
Автор

Is it right sir???
lst=[ ]
size=int(input("enter size of list: "))
for i in range(size):
x=int(input("enter elemnt: "))
lst.append(x)
a=lst[0]
lst.remove(lst[0])
lst.append(a)
print("your left shifted list: ", lst)

#And for right shift
lst=[ ]
size=int(input("enter size of list: "))
for i in range(size):
x=int(input("enter elemnt: "))
lst.append(x)
A=lst[size-1]
lst.remove(lst[size-1])
lst.insert(0, A)
print("your right sifted list: ", lst)

Art_mood
Автор

Great video, keep up the incredible work! :)

ComputerScienceSimplified
Автор

Hello sir I have just come in Class XII. Sir there is playlist of yours of 106 videos. Computer Science with Python Class XII Sumita Arora. Can I follow fully that for my Class XII cbse board exam 2022 ?
Is that complete ? (as no reduction now for 2022 board exam students)
It would be nice if you can reply once :)

indianmemeswaala
Автор

Sir in this code why can't we replace a[size-1]=key with a.append(key)? like the results are differing

sanjaybhagat
Автор

Sir, when will 12th online batch for session 2022-23 launch????

keshav_Jl
Автор

who come after live class😇
All the best😍😍

abhi_piitian
Автор

@codeitup Sir I do have my program. Please verify that is it right or wrong
For left shifting :-

a=[]
size=int(input("Enter size="))
for i in range(size):
val=int(input("Enter value="))
a.append(val)
b=[]
for i in range(size-1):
b.append(a[i+1])
b.append(a[0])
print("Original list is=", a)
print("Changed list is=", b)

For right shifting :-

a=[]
size=int(input("Enter size="))
for i in range(size):
val=int(input("Enter value="))
a.append(val)
b=[]
for i in range(size):
b.append(a[i-1])
print("Original list is=", a)
print("Changed list is=", b)

RishiThalakoti
Автор

Sir, if size=5
Then my output for a[3] & a[4] are coming same.
What am i doing wrong?
I saw everything is same...

Deepaksharma-jvcg
Автор

thank god in intro he didnt said
chaliye shuru karte hai
😂😂

ayushgupta
Автор

b=a[0]
for i in range(size-1)
a[i]=a[i+1] sir hum ese condition nh kar sakte is case me.???

nainagupta
visit shbcf.ru