
Ayuda : UnboundLocalError: local variable "i" referenced before assignment
Publicado por tadeo (1 intervención) el 16/10/2018 03:08:27
EL PROBLEMA ESTA EN LA FUNCION FACTURA :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
def cargar (arProdcto,arCantidad):
producto = int(input("ingrese producto : 1-lechuga, 2-tomate, 3 cebolla comun , 4 - manzana verde y 5 - manzana roja"))
while (producto > 5 or producto < 1):
print("reingrese un producto scorrecto")
producto = int(input("ingrese producto : 1-lechuga, 2-tomate, 3 cebolla comun , 4 - manzana verde y 5 - manzana roja"))
cantidad = int(input("ingrese la cantidad de productos por favors , Muchas gracias !!"))
while (producto != 0 and cantidad != 0):
arProdcto.append(producto)
arCantidad.append(cantidad)
producto = int(input("ingrese producto : 1-lechuga, 2-tomate, 3 cebolla comun , 4 - manzana verde y 5 - manzana roja"))
cantidad = int(input("ingrese la cantidad de productos por favors , Muchas gracias !!"))
def mostrar (arreglo):
for i in range (0,len(arreglo)):
print("%d"%(arreglo[i]))
def factura (arProducto,arCantidad): <------- UnboundLocalError: local variable 'i' referenced before assignment
for i in range (0,len(arCantidad[i])):
if arProducto[i]== 1 and arCantidad[i] > 0 :
total = 13 * arCantidad [i]
if arProducto[i]== 2 and arCantidad[i] > 0:
total1= 42 * arCantidad [i]
else :
total1 = 0
if arProducto[i]== 3 and arCantidad[i] > 0 :
total2 = 12 * arCantidad [i]
else:
total2 = 0
if arProducto[i]== 4 and arCantidad[i] > 0:
total3 = 39 * arCantidad [i]
else:
total3 = 0
if arProducto[i]== 5 and arCantidad[i] > 0 :
total4 = 31 * arCantidad [i]
else:
total4 = 0
totaldelDia = total + total1 + total2 + total3 + total4
print("%d",totaldelDia)
#--------------------------------------
productos= []
cantidades = []
cargar(productos, cantidades)
mostrar (productos)
mostrar(cantidades)
print("la facturacion del dia fue : ")
factura(productos, cantidades)
Valora esta pregunta


0