Switch Case Statement in Python implementieren | #Python

preview_player
Показать описание
Inhalt 📚
In diesem Video lernst du, wie man #Schalterblöcke (bzw. #Switch-#Case-Statements) in #Python implementieren kann.

----------------------------------------------------------------------------------------------------------------
💻 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):

print(switch("three")) # Prints "3".
-----------------------------------------------------------------------------------------------------------
Рекомендации по теме
join shbcf.ru