Switch-Case Statement in Python

Publicado em: 23 Abril 2019
no canal de: pwnoverflo
32,482
327

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".
-----------------------------------------------------------------------------------------------------------


Nesta página do site você pode assistir ao vídeo on-line Switch-Case Statement in Python duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário pwnoverflo 23 Abril 2019, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 32,482 vezes e gostou 327 espectadores. Boa visualização!