“Python Switch Case 3.10” Code-Antworten

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

Schaltkoffer 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

Ähnliche Antworten wie “Python Switch Case 3.10”

Fragen ähnlich wie “Python Switch Case 3.10”

Weitere verwandte Antworten zu “Python Switch Case 3.10” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen