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.

Python Python Basics Types and Branching Booleans

Pete Choi
Pete Choi
Courses Plus Student 153 Points

For boolean arguments e.g. >> 7 and "" . Wouldn't this technically be both true? Since bool(7) and bool("") = True?

bool(7) True bool("") True 7 and "" ' '

Is it because they are two different data types?

1 Answer

Mark Sebeck
Mark Sebeck
Treehouse Moderator 32,258 Points

Hi Peter. bool(7) and bool("") would actually be False. Remember with "and" all arguments have to be True for it to be True. While bool(7) is True, bool("") is empty so its False. And True and Flase is False. If you used "or" it would be True since with ors only one arguement has to be True for it to be True.

bool(7) = True
bool("") = False
bool(7) and bool("")  = True and False = False
bool(7) or bool("")  = True or False = True