match/case statement raises SyntaxError in PyCharm [closed] - python

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
The community reviewed whether to reopen this question 8 months ago and left it closed:
Original close reason(s) were not resolved
Improve this question
I'd like to use the match/case statement but currently PyCharm does not like it and when I try to run this code:
def test(action):
match action:
case "send":
pass
case "create":
pass
case "dump":
pass
it tells me
match action:
^
SyntaxError: invalid syntax
I use python 3.9.1 and PyCharm 2021.2.3 Pro. The keywords match and case are blue so I guess PyCharm recognizes them but is not able to run it. What am I missing here?

You are using Python version less than 3.10.
PEP 634: Structural Pattern Matching is introduced in python 3.10. See What’s New In Python 3.10
for more information.

Related

Are all the dependencies available in this tiny compiler written in python to get this to work [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
https://github.com/AZHenley/teenytinycompiler.git
Can you get this to run I got it from this website:
http://web.eecs.utk.edu/~azh/blog/teenytinycompiler1.html
I followed this tutorial and it failed to load the source file.
I am new to python.
this is a screenshot of when I ran the python project
You never pass in the source file. The command you have now only starts the TeenyTiny compiler. You can pass in the source file as follows.
"C:/Users/Ackeem/AppData/Local/Programs/Python/Python39/python.exe" "C:/Users/Ackeem/Desktop/teenyTIny Compiler/teenytinycompiler/part2/teenytiny.py" "C:/Users/Ackeem/Desktop/teenyTIny Compiler/teenytinycompiler/part2/hello.tiny"
Your code did run but there were no parameters passed to it.
sys.argv is the object that holds parameters being passed.

Why is it giving me this syntax error? I’m following a tutorial. (Beginner) [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
It's saying there's a syntax error (seems simple enough) but I've double-checked the video (and my brain). I don't see why it would be saying that.
Been following this tutorial and taking notes to a T (if I need to include more code let me know).
I defined "run_test" and am entering the parameters in question. Help?
You have extra opening parenthesis before ‘str(len(...))’
There should be a closing brackets for str in print statement ')' , add this and your program will work
If i am not wrong, you haven't defined the list of questions yet. If you have defined your list of questions it is probably a typing error in your code. If there is the full code under the tutorial you are doing then i would compare my code to the code from the tutorial.

I can't determine why it's raising this SyntaxError [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
https://pastebin.com/TZdMx3pM
Here's the code
This error is raised on line 291:
File "marketTrader.py", line 291
stock_list.remove(preferredStock[0])
^
SyntaxError: invalid syntax
I am runing on MacOS. Does it matter if I'm using Python 2 or 3?
Any help is greatly appreciated!
You forgot to close a parentheses on the previous line, 290.
This kind of syntax error does not depend on Python version or OS.
You could have spotted it easily using an IDE (e.g. PyCharm, EMACS) or a static analyser (e.g. pycheck).
It's a missing ')'
Check the line before:
print(': Starting Active Trader with preferred stock {}...'.format([preferredStock[0]])
stock_list.remove(preferredStock[0])
There is missing a close bracket for print.

error while writing print statement [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
A very simple question but I am struggling.
I am learning through CBT Nuggets and in one video teacher says we use print statement from python 3 as that is more advanced. It means it can take parameters.
jim#jim-beam-VirtualBox:~/Documents/python$ cat 4_IO.py
print('Hellow World!'
print('Hello','World','!')
jim#jim-beam-VirtualBox:~/Documents/python$ python 4_IO.py
File "4_IO.py", line 2
print('Hello','World','!')
^
SyntaxError: invalid syntax
jim#jim-beam-VirtualBox:~/Documents/python$
What is this error and why I am getting and not the teacher when I using the same python version 2.7.10
jim#jim-beam-VirtualBox:~/Documents/python$ python --version
Python 2.7.10
jim#jim-beam-VirtualBox:~/Documents/python$
Your help would be really appreciated.
Its because you forgot the brace on the first line.
print('Hellow World!'
^--brace here

Why does the Python repl print different things for None? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
Today I was playing with a Python dict and I found something weird:
>>> print {}.get('non-existant-key')
>>> a = {}.get('non-existant-key')
>>> print a
None
>>>
Why does the repl print an empty space with the first print and "None" after taking the step of storing the value in the variable a? The thing it tries to print is the same in both cases, so why is there be a difference?
Okay, turns out it wasn't the behaviour of the Python repl, but the (for the rest excellent) bpython repl which I always use. I didn't realise I was using bpython instead of the vanilla python when I was testing this.
In the regular pyton repl it all works as expected. I'll file a bug with bpython about this.

Categories

Resources