Skip to content

Instantly share code, notes, and snippets.

@pablovv72
Created May 26, 2018 23:29
Show Gist options
  • Save pablovv72/7c8a8927d873b32eb2bc4f86535f8b46 to your computer and use it in GitHub Desktop.
Save pablovv72/7c8a8927d873b32eb2bc4f86535f8b46 to your computer and use it in GitHub Desktop.
switch.py
opciones = {
1: 'print("has elegido la opción 1")',
2: 'print("has elegido la opción 2")',
3: 'print("has elegido la opción 3")',
4: 'print("has elegido la opción 4")',
5: 'print("has elegido la opción 5")'
}
opc = input('Introduce tu opción [1-5]: ')
eval(opciones[int(opc)])
@pablovv72
Copy link
Author

Una alternativa al switch/case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment