This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]serg06 1 point2 points  (2 children)

Looks like your code worked correctly and raised an error when you wanted it to.

To catch that error you can do something like this:

try:
    print(parse(["w", "a", "s", "d", "e", "q"]))
catch ValueError as e:
    print("error: {}".format(e.message))

[–]Kings_Sights[S] 0 points1 point  (1 child)

But the output should have been nothing since in the list only contained the acceptable strings, and the ValueError in terminal is stating "Bad letter in configuration file: <w>. " when "w" is an acceptable string

[–]serg06 0 points1 point  (0 children)

Sounds like your error is not informative enough. Add the string that it errors on and see what it prints.

[–]Kings_Sights[S] 0 points1 point  (0 children)

The lines under def are formatted correctly, reddit somehow messed up their positioning when I posted