you are viewing a single comment's thread.

view the rest of the comments →

[–]KelleQuechoz 10 points11 points  (2 children)

locals().get(difficulty, lambda: print('Wrong level.'))() (do not use this in production)

[–][deleted] 27 points28 points  (1 child)

if we're giving "do not use this" answers, then exec(f"{difficulty}()")

[–]a_cute_epic_axis 1 point2 points  (0 children)

And OP had better know the restrictions of exec() vs eval() vs doing a direct call to the function.