Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Pedro Leitao1,436 Points
"Return False" x " = False"
Why in this case you define the boolean value with "return False"?
def use_gas(self): self.gas -= 50 if self.gas <= 0: return False else: return True
While in this case you use "self.is_moving = False"
def stop(self): if self.is_moving: print('The car has stopped.') self.is_moving = False else: print('The car has already stopped.')
Steven Parker218,487 Points
These function are doing different kinds of things.
Notice that for the use_gas function, the value is being passed back to the caller, so it's part of a return statement.
But for stop, no value is being returned. Instead, the internal value is_moving is being tested; and also changed if needed.