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 Functional Python The Lambda Lambada Reduce

Sahar Nasiri
Sahar Nasiri
7,454 Points

not books

What is different between not books and books in None? Why did Kenneth use not books?

2 Answers

Wait do you mean "blocks"?

Sahar Nasiri
Sahar Nasiri
7,454 Points

No! I mean the books he wrote in the video! Here's the code:

def long_total(a=None, b=None, books=None):
    if a is None and b is None and books is None:
        return None
    if a is None and b is None and books is not None:
        a = books.pop(0)
        b = books.pop(0)
        return long_total(a, b, books)
    if a is not None and b is None and books and books is not None:
        b = books.pop(0)
        return long_total(a, b, books)
    if a is not None and b is not None and books is not None:
        return long_total(a+b, None, books)
    if a is not None and b is not None and not books:
        return long_total(a+b, None, None)
    if a is not None and b is None and not books or books is None:
        return a
print(long_total(None, None, [b.price for b in BOOKS]))
Ross Coe
Ross Coe
5,061 Points

not books means there is no books left - all values have been popped.. what's confusing is how an empty list is not None.. I'm asking about that