Rodripelto

error_logica

May 12th, 2022 (edited)
649
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.02 KB | None | 0 0
  1. # Este código tiene 5 errores de lógica ¿Sabrías encontrarlos?
  2. print("""
  3. 1 Saludar
  4. 2 Presentarse
  5. 3 Pedir información
  6. 4 Despedirse""")
  7. op = int(input("Elige un opción del 1 al 4:"))
  8. while True :
  9.   if op == 1:
  10.     print("Bien venido")
  11.   if op == 2:
  12.     print("Soy tu asesor personal")
  13.   if op == 3:
  14.     print("¿Cual es tu nombre")
  15.     nombre = input()
  16.   elif op == 4:
  17.     print("Hasta la proxima")
  18.     break
  19.   print("""
  20. 1 Saludar
  21. 2 Presentarse
  22. 3 Pedir información
  23. 4 Despedirse""")
  24.   op = int(input("Elige un opción del 1 al 4:"))
  25. # Código corregido
  26.  
  27. while op != "4" :
  28.   print("""
  29. 1 Saludar
  30. 2 Presentarse
  31. 3 Pedir información
  32. 4 Despedirse""")
  33.   op = input("Elige un opción del 1 al 4:")
  34.   if op == "1":
  35.     print("Bien venido")
  36.   elif op == "2":
  37.     print("Soy tu asesor personal")
  38.   elif op == "3":
  39.     nombre = input("¿Cual es tu nombre")
  40.     print(nombre,"Mejor te llamare humano")
  41.   elif op == "4":
  42.     print("Hasta la próxima")
  43.   else:
  44.     print("Lo opción seleccionada no existe")
  45.  
Add Comment
Please, Sign In to add comment