Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python Basics Types and Branching Booleans

Pete Choi
PLUS
Pete Choi
Courses Plus Student 219 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
MOD
Mark Sebeck
Treehouse Moderator 37,777 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