Notifications
Clear all

Python program to add an element at particular index

   RSS

0
Topic starter

Output Example:
[10,21,'abc','xyz']

enter the index:2
enter the element : hello

new list: [10,21,'hello','abc','xyz']

1 Answer
0
Topic starter

lst=[2,3,4,'abc','hello',100]

index=int(input('enter the index number: '))

n=input('enter the element to be added: ')

lst.insert(index,n)

print('new list: ',lst)

Share: