I am trying to recognise user typed strings such as “exit” or “add number” using this:
command, data = input('>').split(" ", 1)
It works for two word input, but not one word of input (“need more than 1 value to unpack”).
What is the best way of accepting both one/two word inputs?
The best way is to build a parser, but if you just want something to work quickly you could just have a list of the commands you want to allow, such as:
Then for each command check if your input satisfies
s.startswith(command). If so, you can do the appropriate thing for that command.