Last active
May 28, 2024 05:58
-
-
Save AlvisonHunterArnuero/1408e7da105396db4e330cefa206a30b to your computer and use it in GitHub Desktop.
Ayuda con una tarea de un amigo internauta en apuros para aprender Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
opcion_invalida = "Opción inválida. ¡Intente de nuevo!" | |
msg_despedida = "¡Muchas gracias! ¡Que tenga un buen día!" | |
porc_comunes = ["1.1", "2.2", "3.3", "4.4", "5.5"] | |
while True: | |
dar_propina = input("¿Desea dejar propina? ").lower() | |
if dar_propina not in ["si", "no"]: | |
print(opcion_invalida) | |
continue | |
elif dar_propina in ["no"]: | |
print(msg_despedida) | |
break | |
else: | |
print("¿Cuánto % desea usted dejar? Escriba el primer dígito del porcentaje abajo:") | |
print("--" * 20) | |
joined_string = "0% | ".join(porc_comunes) | |
porcentaje_str = input(f"{joined_string}0% \n") | |
if not porcentaje_str.isdigit() or int(porcentaje_str) not in range(6): | |
print(opcion_invalida) | |
continue | |
porcentaje = int(porcentaje_str) * 10 | |
print("--" * 20) | |
print(f"¡Agradecemos su propina del {porcentaje}%!") | |
print(msg_despedida) | |
print("--" * 20) | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment