Basic operations in Python List

n=int(raw_input('Enter the no of elements added to list:'))
for i in range(n):
      element=int(raw_input('Enter the elements:'))
print '\nNew List is ',
m=int(raw_input('\nEnter the no of elements added to list using insert:'))
for i in range(m):
      u=int(raw_input('Enter the index to be added'))
      u1=int(raw_input('Enter the element to be added'))
print '\nNew List after insert operation is:   ',l
ch=int(raw_input('\nPress 1 to pop the last element\nPress 2 to pop the element in a particular index\nEnter the choice: '))
if ch==1:
 print '\nNew List after deletion is: ',l
elif ch==2:
 p=int(raw_input('Enter the element index to be deleted'))
 print '\nNew List after deletion is: ',l
  print '\nInvalid choice'
print ' \nList elements are sorted:  ',l

No comments: