Skip to main content

Popping element from list in python

 

Modify short_names by deleting the first element and changing the last element to Joe


Sample output with input : "Jig Jag Jam Jim"

['Jag', 'Jam', 'Joe']



 user_input = input()
 short_names = user_input.split()
 short_names.pop(0)
 short_names[-1] = 'Joe'
 print(short_names) 

Hope this is helpful. Write back to me in case you need help with your python task. I generally reply back within 24 hours. You can connect with me on Whatsapp also: +918602715108

Comments