How to use switch statement with strings in Python

1 Answer

0 votes
s = "Python"

match s:
    case "Foo":
        print("Foo")
    case "Wii":
        print("Wii")
    case "Python":
        print("Python")
    case "YYI":
        print("YYI")
    case _:
        print("No match found.")
        

'''
run:

Python

'''

 



answered Jul 1, 2025 by avibootz

Related questions

1 answer 114 views
1 answer 91 views
1 answer 108 views
1 answer 94 views
1 answer 92 views
1 answer 102 views
...