Hello, I am making a shopping cart system and when asking me to return the purchase information, it does not store all the values entered, it only delivers the last value entered.
def opc1():
global lis
lis=[]
s="si";
while(s=="si" or s=="SI"):
print("---------------Lista de Productos--------------");
cont=1;
for i in lis:
print(cont,".-nombre : ",i[0]," $",i[1]);
cont=cont+1
else:
nombre=input("Introduzca nombre producto : ");
valor=int(input("Introduzca valor del producto : "));
s=input("¿Desea ingresar un nuevo producto? si - no : ");
lis=lis + [[nombre,valor]]
ing();
The rest of the code is as follows: Hi, thanks for your answer, my problem is that when you arrive at the shopping cart you do not store all the items entered, only the last thing you entered.
def opc2():
global v;
v=[]
print("");
print(" *****REALIZAR VENTA*****");
print("");
print("---------------Lista de Productos--------------");
cont=1;
f print("");
nom=int(input("Introduzca numero de producto a comprar : "));
can=int(input("Introduzca cantidada comprar de dicho producto : "));
res=nom-1;
cans=lis[res][1]*can;
print("");
print("--------------------------------------------");
print("");
print("******Carrito de compra*****");
print("");
print("---------------Lista de Productos--------------");
cont=1
print("");
and I think the fault I have is in this section of code:
print(cont,".-",lis[res][0],"Cantidad : ",can,"$",cans );
v= [lis[res][0],cans+cans]
print(v);
print("");
print("--Acciones--");
print("");
print("Presione S para seguir comprando");
print("");
print("Presione numero de producto que desea quitar");
print("");
p=input("introduzca opcion de acuerdo cuatro anterior");
if(p=="s" or p=="S"):
opc2()
ing();