How to add and remover items from a list

arthur190181

arthur

Posted on June 11, 2021

How to add and remover items from a list

Iam learning how to use lists in pyhton, but iam having problems with my code, that´s about a grocery cart.
while True:
n = input().split()
comand = input()
lista = [n]
if comand == 'show':
lista.sort()
if comand == 'add':
lista.append(input())
if comand == 'remove':
lista.pop()
if comand == 'terminate':
break
print(lista)

show == show itemns in ascending order
add == adding a new number
remove == removing a number of the list
terminate == exit

if you cannot help thanks for just read my problem :)

💖 💪 🙅 🚩
arthur190181
arthur

Posted on June 11, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related