<gh_stars>0
"""
Exercise 2
"""

# PART 1: Gather Information
#
# TODO: Gather information about the source of the error and paste your findings here. E.g.:

# - What is the expected vs. the actual output?
#: We expected input of [4, 1, 2, 3] to return True when it returns False

# - What error message (if any) is there?
#: There is no error message

# - What line number is causing the error?
#:  Line 32 where the else statement was

# - What can you deduce about the cause of the error?
#: We can say that with an if else statement either one or the other must get executed 

# PART 2: State Assumptions
#
# TODO: State your assumptions here or say them out loud to your partner ...
# Make sure to be SPECIFIC about what each of your assumptions is!
#: We are assuming that the loop with continue for all the values in the array but it is not.

def contains_3_consecutive(list_of_nums):
    """Return True if the list contains 3 consecutive numbers each increasing by 1."""
    for i in range(len(list_of_nums) - 2):
        if (list_of_nums[i+1] == list_of_nums[i] + 1 and
            list_of_nums[i+2] == list_of_nums[i] + 2):
            return True

    return False

if __name__ == '__main__':
    print('### Problem 2 ###')
    answer1 = contains_3_consecutive([1, 2, 4])
    print(answer1) # should print False

    answer2 = contains_3_consecutive([4, 1, 2, 3])
    print(answer2) # should print True
"""
Exercise 2
"""

# PART 1: Gather Information
#
# TODO: Gather information about the source of the error and paste your findings here. E.g.:

# - What is the expected vs. the actual output?
#: We expected input of [4, 1, 2, 3] to return True when it returns False

# - What error message (if any) is there?
#: There is no error message

# - What line number is causing the error?
#:  Line 32 where the else statement was

# - What can you deduce about the cause of the error?
#: We can say that with an if else statement either one or the other must get executed 

# PART 2: State Assumptions
#
# TODO: State your assumptions here or say them out loud to your partner ...
# Make sure to be SPECIFIC about what each of your assumptions is!
#: We are assuming that the loop with continue for all the values in the array but it is not.

def contains_3_consecutive(list_of_nums):
    """Return True if the list contains 3 consecutive numbers each increasing by 1."""
    for i in range(len(list_of_nums) - 2):
        if (list_of_nums[i+1] == list_of_nums[i] + 1 and
            list_of_nums[i+2] == list_of_nums[i] + 2):
            return True

    return False

if __name__ == '__main__':
    print('### Problem 2 ###')
    answer1 = contains_3_consecutive([1, 2, 4])
    print(answer1) # should print False

    answer2 = contains_3_consecutive([4, 1, 2, 3])
    print(answer2) # should print True
Exercise 2 # PART 1: Gather Information # # TODO: Gather information about the source of the error and paste your findings here. E.g.: # - What is the expected vs. the actual output? #: We expected input of [4, 1, 2, 3] to return True when it returns False # - What error message (if any) is there? #: There is no error message # - What line number is causing the error? #:  Line 32 where the else statement was # - What can you deduce about the cause of the error? #: We can say that with an if else statement either one or the other must get executed # PART 2: State Assumptions # # TODO: State your assumptions here or say them out loud to your partner ... # Make sure to be SPECIFIC about what each of your assumptions is! #: We are assuming that the loop with continue for all the values in the array but it is not. Return True if the list contains 3 consecutive numbers each increasing by 1. ## Problem 2 ###') # should print False # should print True