DEV Community

Discussion on: How to add and remover items from a list

Collapse
 
walter11 profile image
Atharv-777

n = input('Enter your choice : ').split()
lista = list(n)
while True:
comand = input('Your command : ')
if comand == 'show':
lista.sort()
if comand == 'add':
lista.append(input())
if comand == 'remove':
lista.pop()
if comand == 'terminate':
break
print(lista)

Try this code, it is working..
Actually in your code "lista" was not getting updated, so take it outside while loop.