How do I make this return True, only once, when there are no bad characters for example no colons. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How do I make this return True, only once, when there are no bad characters for example no colons.

https://code.sololearn.com/cPgphPnOQ74T/?ref=app

18th Jun 2019, 2:53 PM
David Nierman
David Nierman - avatar
6 Answers
+ 4
Yes. Make it so that the return True is on the same indentation level as the "for" in line 7. This way, it'll first go through the whole loop and return False if a bad character was found. If it didn't find a bad character throughout the whole loop, it will return True
18th Jun 2019, 3:09 PM
Anna
Anna - avatar
+ 3
Functions don't really have return types in Python. You can use annotations to express what kind of parameters your function expects and what it is supposed to return: def add(x:int, y:int) -> int: return x+y However that doesn't stop you from calling the function with floats or strings or having the function return a list, boolean or any other type
19th Jun 2019, 5:57 AM
Anna
Anna - avatar
+ 2
Use functions with return type Boolean ! 🤔
19th Jun 2019, 3:43 AM
Sanjay Kamath
Sanjay Kamath - avatar
+ 1
Just add "return True" after the for loop
18th Jun 2019, 2:59 PM
Anna
Anna - avatar
+ 1
Anna I forgot to mention I want it to return True only once not for each character
18th Jun 2019, 3:04 PM
David Nierman
David Nierman - avatar
0
Sanjay Kamath can you give me an example of a function with return type Boolean?
19th Jun 2019, 3:49 AM
David Nierman
David Nierman - avatar