Validation funcation to test the established funcation | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Validation funcation to test the established funcation

https://pythonprinciples.com/challenges/Solution-validation/ How can will be the mechanism for this challenge

2nd Jan 2024, 8:04 AM
Mohammed Hassan
Mohammed Hassan - avatar
8 Answers
+ 5
You receive a string as input and check all the things step by step and output messages as described. That‘s all. It looks more difficult than it is.
2nd Jan 2024, 8:20 AM
JaScript
JaScript - avatar
+ 3
But there in the description will be requested to work in following way: def validate(mystr): if 'def' not in mystr: return 'missing def' # etc. … your code
2nd Jan 2024, 12:16 PM
JaScript
JaScript - avatar
+ 2
JaScript but how i can write code in output screen because there is also condition of return statment?
2nd Jan 2024, 9:27 AM
Mohammed Hassan
Mohammed Hassan - avatar
+ 2
This the same as here, with the print statement: myin = input() if 'def' not in myin: print('missing def')
2nd Jan 2024, 11:55 AM
JaScript
JaScript - avatar
+ 2
👍
3rd Jan 2024, 2:45 AM
Apocalipsis
Apocalipsis - avatar
+ 1
Mohammed Hassan , Nice challenge site. I notice that the "Solution Validation" challenge is rated difficulty 5/10. There are 18 challenges of lower difficulty than that. If you're having trouble understanding this one, maybe you should finish those first. https://pythonprinciples.com/challenges/
3rd Jan 2024, 12:48 AM
Rain
Rain - avatar
+ 1
def validate(f): if 'def' not in f: return 'missing def' if ':' not in f: return 'missing :' if ( '(' not in f and ')' not in f ) : return 'missing paren' if chr(40)+chr(41) in f: return 'missing param' if ' ' not in f: return 'missing indent' if 'validate' not in f: return 'wrong name' if 'return' not in f: return 'missing return' return True
3rd Jan 2024, 3:35 AM
Bob_Li
Bob_Li - avatar
0
How to find sum of odd number
3rd Jan 2024, 2:45 PM
ANANTHA GOPAN 89
ANANTHA GOPAN 89 - avatar