“Python Switch Case 3.10” Réponses codées

Python Switch Case 3.10

grade = 92
category = grade//10  # Well above average grade
match category:
	case 10:
		print("Excellent")
	case 9:
		print("Well above average")
	case 8:
		print("Above average")
	case 7:
		print("Average")
	case 6:
		print("Below average")
	case _:
		print("Not passing")
Wissam

Switch Case Python 3.10

def my_function(status):
    match status:
        case 400:
            return "Bad request"
        case 404:
            return "Not found"
        case 418:
            return "I'm a teapot"
        case _:
            return "Something's wrong with the internet"

# No need of break after case
Frustrated Developer

Réponses similaires à “Python Switch Case 3.10”

Questions similaires à “Python Switch Case 3.10”

Plus de réponses similaires à “Python Switch Case 3.10” dans Python

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code