Challenge
(invalid)
(invalid)
(invalid)
(invalid)
(invalid)
(invalid)
(invalid)
(invalid)
(invalid)
(invalid)
Solution validation
The aim of this challenge is to write code that can analyze code submissions. We'll simplify things a lot to not make this too hard.
Write a function named validate that takes code represented as a string as
its only parameter.
Your function should check a few things:
- the code must contain the
defkeyword- otherwise return
"missing def"
- otherwise return
- the code must contain the
:symbol- otherwise return
"missing :"
- otherwise return
- the code must contain
(and)for the parameter list- otherwise return
"missing paren"
- otherwise return
- the code must not contain
()- otherwise return
"missing param"
- otherwise return
- the code must contain four spaces for indentation
- otherwise return
"missing indent"
- otherwise return
- the code must contain
validate- otherwise return
"wrong name"
- otherwise return
- the code must contain a
returnstatement- otherwise return
"missing return"
- otherwise return
If all these conditions are satisfied, your code should return True.
Here comes the twist: your solution must return True when validating itself.
(invalid)
(invalid)
(invalid)
(invalid)
(invalid)
(invalid)
(invalid)
(invalid)
(invalid)
(invalid)
(invalid)
(invalid)
(invalid)
(invalid)