Question: Write a function sum_5_consecutive that takes a list of numbers as input and returns True if there are 5 consecutive numbers in the list that

Write a function sum_5_consecutive that takes a list of numbers as input and returns True if there are 5 consecutive numbers in the list that sum to zero. Otherwise it returns False. The function should also return False if the list has less than 5 elements Solve this in two ways: 1.for loop (over indices of the list) 2. while loop (over indices of the list) In both cases you need to think about "stopping condition" in order to avoid "Indexerror: list index out of range" 3. Test your function with at least the examples below >um_5_consecutive ([2,3,3,2,4,6]) True >>> sum_5_consecutive ([10,1,1,4,2,10,13]) False >> sum_5_consecutive ([2,1,3,3,3,2,7,4,6]) True >>> sum_5_consecutive ([]) False >> sum_5_consecutive ([1,1,0]) False
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
