0

Creating a todo list that uses the "match" function:

while True:
    user_action = input("Type add, show, edit, or exit: ")
    user_action = user_action.strip()

    match user_action:
        case "add":
            todo = input("Enter a todo: ")
            todos.append(todo)
            file = open("todos.txt", "w")
            file.writelines(todos)

Here is what happens:


Traceback (most recent call last):
  File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in <module>
    start(fakepyfile,mainpyfile)
  File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start
    exec(open(mainpyfile).read(),  __main__.__dict__)
  File "<string>", line 7
    match user_action:
          ^
SyntaxError: invalid syntax

I suspect that there is no "match" function in PyDroid. Sorry, but I'm quite new at this. Is there something I'm missing or some way I can make a work-around? Thanks in advance!

ricoNomad
  • 1
  • 2

1 Answers1

0

It seems the real problem here is that the version of PyDroid is 3.9.7, which is to say, it does not contain the "match" function.

Adriaan
  • 17,741
  • 7
  • 42
  • 75
ricoNomad
  • 1
  • 2
  • Please do not add follow-up questions into your answers. If you have a related but different question, [ask a new question](https://stackoverflow.com/questions/ask), and include a link to this one to help provide context. See: [Ask questions, get answers, no distractions](https://stackoverflow.com/tour). – Adriaan Nov 21 '22 at 08:46
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 25 '22 at 18:56