0

I am not able to understand what the return statement do-true and false do here .can someone explain the same with example .

def dun(word,required): for letter in required: if letter not in word: return false return true

8th Jan 2019, 4:11 AM
Mara
2 Respuestas
0
This is a function with two parameters. The function is called somewhere in the program, does its thing then the result is passed back to the caller with the return statement. Example call: has_letter = dun('hello', 'ho') So the function cycles though all the letters of the 'required' parameter. If any of those letters is not found in the 'word' then the return value is False (and the function execution stops). If all the letters are found then the for loop finished and the value True is returned. In the end the return value is assigned to the variable (called 'has_letter' in my example)
8th Jan 2019, 6:39 AM
Tibor Santa
Tibor Santa - avatar
0
True and False are boolean keywords in Python. The number 0 and an empty list [] are also considered equal to False
8th Jan 2019, 6:42 AM
Tibor Santa
Tibor Santa - avatar