Hello,
How to make a switch case in python 3 that works with Grist?
Hello,
How to make a switch case in python 3 that works with Grist?
Python doesn’t have ‘switch’ but it does have match/case
statements, which are slightly different from switch
in other programming languages.
However, these are a very new feature that only came out in Python 3.10, the latest stable version. Grist currently uses Python 3.9 (or 2.7 for old documents) so it doesn’t have match/case
.
This means that you have to use plain if/elif/else
. If you’re having trouble getting a formula to do what you want, we’re here to help.
Hello,
I had tried the match/case by looking at the Python documentation, but it didn’t work.
Now I understand: Grist incorporates version 3.9 and not 3.10.
Thank you for this remark.
Grist now uses Python 3.11! So you can use match/case statements.