Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Use python to solve this Problem A run is a sequence of consecutive repeated val

ID: 3722978 • Letter: U

Question

Use python to solve this Problem

A run is a sequence of consecutive repeated values. Implement a Python function called two_length_run that takes a list of numbers as input and returns True if the given list has is at least one run (of length at least two), and False otherwise. Make sure the function is efficient (i.e. it stops as soon as the answer is known). Then, in the main, your program should ask the user to input the list, then it should call two_length_run function, and print the result. You may assume that the user will always enter at least two elements, but your function two_length_run should work for all lists of numbers including those of length 0 and 1. Examples of program runs: Example 1: Please input a list of numbers separated by commas: 1,4,3,3,4 True Example 2: Please input a list of numbers separated by commas: 1,2,3,3,3,4,6,5 True Example 3: Please input a list of numbers separated by commas: 1,2,3,4,3,2 False

Explanation / Answer

def two_length_run(a):
for i in range(len(a)-1):
if a[i]==a[i+1]:
return True
return False


def main():
a1 = input("Enter numbers seperated with comma ")
k1=a1.split(",")
print(two_length_run(k1))
a2 = input("Enter numbers seperated with comma ")
k2=a2.split(",")
print(two_length_run(k2))

main()