# A Common-Sense Guide to Data Structures and Algorithms in Python, Volume 1: logic error (pg. 45)

**URL:** <https://forum.devtalk.com/t/a-common-sense-guide-to-data-structures-and-algorithms-in-python-volume-1-logic-error-pg-45/195838>\
**Category:** PragProg Customers\
**Tags:** book-a-common-sense-guide-to-data-structures-and-algorithms-in-python-volume-1, errata\
**Created:** [21 April 2025 02:53 UTC](https://forum.devtalk.com/t/a-common-sense-guide-to-data-structures-and-algorithms-in-python-volume-1-logic-error-pg-45/195838 "2025-04-21T02:53:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dsletten](https://forum.devtalk.com/user_avatar/forum.devtalk.com/dsletten/32/7340_2.png) [@dsletten](https://forum.devtalk.com/u/dsletten)\
**Post date:** [21 April 2025 02:53 UTC](https://forum.devtalk.com/t/a-common-sense-guide-to-data-structures-and-algorithms-in-python-volume-1-logic-error-pg-45/195838/1 "2025-04-21T02:53:41Z")

</div>

@jaywengrow  
Exercise 1. on pg. 45 examines the time complexity of the determination of a leap year. However, the logic of the first branch is backwards. Here is the correct definition:

```auto
def is_leap_year(year):
    if year % 100 == 0:
        if year % 400 == 0:
            return True
        else:
            return False

    return year % 4 == 0

```
