This should be the easiest thing ever, I have never felt so dumb before. I had a lot of else-if's in my code, so I attempted to change it to a match to be fancy. I have tried Python on my computer and repl (the website), I have tried example code from every website I could go to, but no matter what I try it says the syntax after "match" is wrong. The exact error for the code (pasted below) is:
File "main.py, line 5
match cpuModel:
^
SyntaxError: invalid syntax
That error was from REPL. Here is the code that is NOT MINE, however, as the error is exactly the same as my code and this is far more readable than my code, and proves that even internet example code does not work for me, I feel like this is a reasonable substitute.
# First, ask the player about their CPU
cpuModel = str.lower(input("Please enter your CPU model: "))
# The match statement evaluates the variable's value
match cpuModel:
case "celeron": # We test for different values and print different messages
print ("Forget about it and play Minesweeper instead...")
case "core i3":
print ("Good luck with that ;)")
case "core i5":
print ("Yeah, you should be fine.")
case "core i7":
print ("Have fun!")
case "core i9":
print ("Our team designed nice loading screens… Too bad you won't see them...")
case _: # the underscore character is used as a catch-all.
print ("Is that even a thing?")
This code is from https://www.udacity.com/blog/2021/10/python-match-case-statement-example-alternatives.html. I know I could use else and if's and even the amazing "elif", but I just want to understand what is going wrong for me.
The summary: It is not my code or my computer's instillation of Python, example code does not work for me and an online IDE that does not require Python to be on my computer. Both my code and online code does not have proper syntax for a "match" statement. All I am asking is for the proper syntax on a match statement. A single example that works.
If it is important, I am personally running Python 3.11
as is REPL. I feel absolutely goofy asking for help on the syntax of match, but I am about to commit crimes to my bathroom.