Question: Use python! Going for a run! To get started, write a function called run(string, Index) that takes as input a string and a number called

Use python!
 Use python! Going for a run! To get started, write a
function called run(string, Index) that takes as input a string and a
number called index and returns the number of identical consecutive digits in
the string beginning at position index. Whew, that's a mouthful; a few

Going for a run! To get started, write a function called run(string, Index) that takes as input a string and a number called index and returns the number of identical consecutive digits in the string beginning at position index. Whew, that's a mouthful; a few examples will help. run("11121,) Notice that index 0 we find the symbol "1" and there are three consecutive 1's before that "run" is broken by a dfferent symbol (a pesky 2). So, run returned 3 in this case. Here's another one: o run("11999913", 2) In this case, beginning at index 2 we have four consecutive 9's so the run has length 4 Your run function will use some sort of loop. It turns out that a while loop is a much better choice here than a for loop. Do you see why? A quick refresher on the anatomy of while loops. The general form is this while BLAH blah, blah, blah where BLAH is a Boolean expression; that is, something that is either True or False. Here are a few examples. This one starts with a variable x set to o. Then, while x is less than 10, we print x and try again. Eventually, x down and print "Hey, I finished!" increment it. Then, we try again. Eventually, x will become 10 and the loop ends. At that point, we drop

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!