Switch-Case Statement in Python

Pubblicato il: 23 aprile 2019
sul canale di: 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".
-----------------------------------------------------------------------------------------------------------


In questa pagina del sito puoi guardare il video online Switch-Case Statement in Python della durata di ore minuti seconda in buona qualità , che l'utente ha caricato pwnoverflo 23 aprile 2019, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 32,482 volte e gli è piaciuto 327 spettatori. Buona visione!