Question: In Python A run is a sequence of letters that are all identical. A string can contain many runs. The shortest run has length one.

In Python A run is a sequence of letters that are all identical. A string can contain many runs. The shortest run has length one. The longest possible run is the entire string. Heres a string with 3 runs: AA7777CCC. The lengths of the runs are 2, 4, and 3, respectively.

Write a function called rising_runs(s) that accepts a string, s, containing one or more runs. The function should examine the runs in s, and it should display is rising if the lengths of the runs dont decrease in length. So, 3, 3, 7, 9 is a rising collection, while 3, 3, 9, 7 is not. The function should display is not rising in this case. Your function must not process the entire string unless necessary. (So, using the groupby function is not allowed.)

Write a main driver that repeatedly asks the user to enter a string containing runs until the user enters a run of length zero. The characters in the string can be any character at all alphabetics, numeric, punctuation, whatever.

Run your program several times using different inputs sufficient to demonstrate that your program meets all the assignment requirements. Capture a screen shot of each run and paste them into an MS Word document. Place a caption above each image.

Here is my program so far, but the sequence is a bit off and I need some assistance. Thank you.

def rising_runs(s): if(len(s) == len(set(s))): return "This is a rising run. " else: return "This is not a rising run. "

Running = True

def stop(a, b): # Global so that the outer Running is set global Running Running = False

print("Does a string contain rising runs? ")

while Running: user_input = input("Enter a string: ") if(user_input == ""): print(" Done!") exit() else: print(rising_runs(user_input))

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!