+ 1
Control Flow
What does match case do in Python?
3 Answers
+ 6
it known as switch statements, it work like if/else but cannot handle floating values.
+ 3
When you have to compare something several times, you can write a bunch of IF statements. Match Case is a simple way to do that. You can always do this with IF statements. But it's a little easier to read like this.
Look at this function:
def http_error(status):
match status:
case 400:
return "Bad request"
case 404:
return "Not found"
case 418:
return "I'm a teapot"
+ 2
Thank you đđđđđ