How can you implement a switch-case statement in Python? In this video you will find the answer!
----------------------------------------------------------------------------------------------------------------
💻 Code (Version 1) 💻
def switch(value):
return {
"one" : 1,
"two" : 2,
"three" : 3,
"four" : 4,
"five" : 5
}.get(value, 42)
print(switch("three")) # Prints "3".
-----------------------------------------------------------------------------------------------------------
💻 Code (Version 2) 💻
dict = {
"one" : 1,
"two" : 2,
"three" : 3,
"four" : 4,
"five" : 5
}
def switch(value):
return dict.get(value, 42)
print(switch("three")) # Prints "3".
-----------------------------------------------------------------------------------------------------------
En esta página del sitio puede ver el video en línea Switch-Case Statement in Python de Duración hora minuto segunda en buena calidad , que subió el usuario pwnoverflo 23 abril 2019, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 32,482 veces y le gustó 327 a los espectadores. Disfruta viendo!