Question: In python Exercise 3 (8 pts) Write a function named all equal that returns True if all values in a list are the same, False
In python
Exercise 3 (8 pts) Write a function named all equal that returns True if all values in a list are the same, False otherwise. The function should take as a parameter a list named a_list. The function should iterate through the list using a loop and compare consecutive elements (elements at position i and i+1). If at any point two consecutive elements are not equal, the function returns Palse. If the loop reaches the end of the list, it must be the case that all the values are the same, so the function will return True. Note that since the loop needs to compare consecutive elements it will need to iterate by index (not be element). To test that the function works correctly, in a main function, call all_equal on a list where all elements are equal and on another list where that's not the case. Output the result
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
