I tried to solve some basic CS50 python problems and got stuck with this one (I know it can be done just by using ifs). Basically you need to print the file extension, so i split the filename to get ["filename", "extension"], and to this point it does work ok.
However no matter what i input it always print "error". Here's the code:
filename = input("Enter filename: ")
extension = filename.split(".")
match extension:
case ["jpg"]:
print("this is a jpg file")
case ["gif"]:
print("this is a gif file")
case _:
print("error")
I also tried some examples from different sites and it always prints the last case. Python version is 3.10.6. Any ideas?