I can accept user's input in two formats:
123123,234,6028
I need to write a function/a few lines of code that check whether the input follows the correct format.
The rules:
- If a single number input, then it should be just a number between 1 and 5 digits long
- If more then one number, then it should be comma-separated values, but without spaces and letters and no comma/period/letter allowed after the last number.
The function just checks if formatting correct, else it prints Incorrect formatting, try entering again.
I would assume I would need to use re module.
Thanks in advance
str.split, among other options. Its not going to be a big deal either way. If you likere, try an implementation and come back if you need specific help.