ricoNomad
ricoNomad

Reputation: 1

Problems with "match" function in PyDroid3

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!

Upvotes: 0

Views: 192

Answers (1)

ricoNomad
ricoNomad

Reputation: 1

It seems the real problem here is that the version of PyDroid is 3.9.7. This version of pydroid, has a not too recent Python version which does not yet support the match-case statements.

Upvotes: 0

Related Questions