+ 2
How do I make this return True, only once, when there are no bad characters for example no colons.
6 odpowiedzi
+ 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
+ 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
+ 2
Use functions with return type Boolean ! 🤔
+ 1
Just add "return True" after the for loop
+ 1
Anna I forgot to mention I want it to return True only once not for each character
0
Sanjay Kamath can you give me an example of a function with return type Boolean?