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 trialNicole Buckenwolf
8,721 PointsWhy a space before `True`?
This is more just an observation/curiosity but I'm wondering if anyone knows if there's an actual reason for this or if it's just a quirk.
In the Introduction to Numpy video about Boolean Array Indexing I noticed that when Craig creates this example
np.array([False, True, True]) & np.array([True, False, True])
The result comes back as
array([False, False, True])
I am just curious if anyone knows why in True gets an extra space before it? If you change the values around, for instance
np.array([True, True, True]) & np.array([True, False, True])
You get
array([ True, False, True])
Thanks!
2 Answers
Rohald van Merode
Treehouse StaffHi Nicole Buckenwolf 👋
Great question! This is NumPy's way to print arrays, improving readability. By adding some white space the character length of all values are the same and therefor everything is nicely printed in columns. You can see the same thing happening with the numbers a little later in the video 🙂
Nicole Buckenwolf
8,721 PointsOhhh columns, that makes so much sense. Thank you!!!