Intermediate
Validate arguments against a schema
Write validate(schema, args) that returns a list of problem strings (empty when the arguments are fine). schema has properties (each with a type of "string" or "integer") and required.
Problems, in this order: first, for each name in required that is missing: "missing required argument: <name>". Then, for each key in args in order: "unknown argument: <key>" if the schema has no such property, or "<key>: expected <type>" if the value has the wrong type. A bool is not an integer.
What Check tests
- Good arguments give
[] - A missing required argument is reported
- A wrong type is reported
- An unknown argument is reported
- A boolean is not an integer
- All problems are reported together
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
main.py
Sign in to run your code.
Output
Press Run to see what your program prints.