About 4,090,000 results
Open links in new tab
  1. Return True, False and None in Python - Stack Overflow

    Mar 24, 2013 · I have function a call function b (returns True or False to a), afterwards function a can return the result to be printed. ... def a(self, data): p = self.head. return self.b( p,data) def b(self, p, data): current = p. if current.data == data: return True. …

  2. python - Return True/False - when to use it over just return

    Aug 19, 2016 · If it returns a value like True or False, you can in turn use the return value of your function in cases like: if test(8): # do something it returns True else: # do something otherwise Otherwise, you function is meaningless because test() …

  3. Python Function return True/False - Stack Overflow

    Mar 6, 2018 · def isLeapYear(n): if n % 400 == 0: print ("The year", n, "is a leap year:") return True if n % 100 == 0: print ("The year", n, "is a leap year:") return False if n % 4 == 0: print ("The year", n, "is a leap year:") return True else: print ("The year", n, "is a leap year:") return False isLeapYear(2000)

  4. The Python return Statement: Usage and Best Practices

    In this step-by-step tutorial, you'll learn how to use the Python return statement when writing functions. Additionally, you'll cover some good programming practices related to the use of return. With this knowledge, you'll be able to write readable, robust, and maintainable functions in …

  5. Python Booleans - W3Schools

    You can evaluate any expression in Python, and get one of two answers, True or False. When you compare two values, the expression is evaluated and Python returns the Boolean answer: Example

  6. Return True or False in Python - Java2Blog

    Dec 4, 2023 · In Python, returning True or False can be achieved through a variety of methods, each suitable for different scenarios. From basic boolean expressions and operators to more complex methods like regular expressions and exception handling, Python provides a rich toolkit for boolean evaluations.

  7. Understanding return True and False in Python

    Jan 12, 2025 · What does return True/False actually do in Python? I’ve added a sample code below to provide context for my question. I often see programs with if statements that return True or False, but what exactly is happening here?

  8. Return "True" or "False" without IF function : r/learnpython

    Sep 5, 2018 · Objects have a __bool__ method defined on them which allows them to look at themselves and return either True (if they're truthy) or False if they're falsey. The correct way to call an object's __bool__ method is to do bool(my_object) .

  9. Python Return Boolean (True/False) From Function

    Oct 14, 2022 · A Python function can return any object such as a Boolean value (True or False). To return a Boolean, you can have an arbitrary simple or complex expression within the function body and put the result of this after the return keyword (e.g., return False ).

  10. Understanding How to Usereturn True’ in Python – A …

    ‘return True’ is more suitable than ‘return False’ or ‘return None’ when we want to explicitly indicate the successful execution of an operation. By returning ‘True’, we clearly communicate that the desired outcome of a function or method has been achieved.

  11. Some results have been removed