How To Perform Various Functions Of A Python List
#PYTHON LIST PROGRAMME
print('PYTHON LIST PROGRAMME ')
x=list()
w=input('\n Do you want to Run Programme (yes / no) :- ')
while(w=='yes' or w=='YES'):
print('\n 1. ADD/APPEND ELEMENT INTO LIST ')
print(' 2. DELETE ELEMENTS FROM LIST ')
print(' 3. SHOW LIST ELEMENT')
print(' 4. QUIT')
c=int(input('\n Enter Function Number :- '))
if(c==1):
y=input('\n Enter Element :- ')
x.append(y)
print('\n Data Stored Successfully !')
elif(c==2):
print(' \nA. DELETE FROM BEGINNING')
print(' B. DELETE FROM END')
print(' C. DELETE BY POSITION')
print(' D. DELETE BY VALUE')
print(' E. SHOW LIST')
print(' F. EXIT')
d=input('\n Enter Function Order :- ')
if(d=='A' or d=='a'):
x.pop(0)
print('\n 1st Element Removed Successfully ! ')
elif(d=='B' or d=='b'):
x.pop(-1)
print('\n Last Element Removed Successfully ! ')
elif(d=='C' or d=='c'):
z=int(input('\n Enter Item Index To Be Removed From Starting :- '))
x.pop(z+1)
print('\n Item Removed Successfully !')
elif(d=='D' or d=='d'):
z=input('\n Enter Item To Be Removed :- ')
x.remove(z)
print('\n Item Removed Successfully !')
elif(d=='E' or d=='e'):
print('\n List = ',x)
elif(d=='F' or d=='f'):
print('\n Thank You For Using The Programme!!')
exit()
else:
print('\n ERROR In Input!')
elif(c==3):
for i in x:
print(i)
elif(c==4):
print('\n Thank You For Using The Programme!!')
exit()
else:
print('\n ERROR In The Input!')
exit()
Made By :-
Nilay Saraf
Comments
Post a Comment