Advertisement
Guest User

Untitled

a guest
May 28th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.95 KB | None | 0 0
  1. nombres = ["hola","como","estas","chucho","puto","chupala","amigo","tito","pobre","chabon","zapallo"]
  2.  
  3.  
  4. def elegir_producto(nombres):
  5.     while True:
  6.         mostrar_productos(5,nombres)
  7.        
  8.                
  9. def mostrar_productos(cantidad_muestra,nombres):
  10.     for numero,producto in enumerate( nombres[:cantidad_muestra],1):
  11.         print("{} : {} ".format(numero,producto))
  12.     seleccion = input("Ingrese el numero del producto que desea, si no esta en la lista ponga \"*\" ")
  13.     if len(seleccion) == 1 and seleccion.isdigit():
  14.             seleccion = int(seleccion)
  15.             return nombres[seleccion-1]
  16.     elif seleccion == "*":
  17.         nombres = nombres[cantidad_muestra::]
  18.         if nombres[:cantidad_muestra] == []:
  19.             print("No se encontraron mas productos. Volviendo al menu principal.")
  20.             return ""
  21.         else:
  22.             return mostrar_productos(cantidad_muestra,nombres)
  23.  
  24. print(mostrar_productos(5,nombres))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement