Question: Now we will write a similar function that finds the doubled letters, and removes the duplicates. This model uses a while loop instead of a

Now we will write a similar function that finds the doubled letters, and removes the duplicates. This model uses a while loop instead of a for loop, because each removal shortens the length of the data. If we used a for loop to count up to the length of the original data, it would count too far. NOTE: Using the while loop means we will need another statement inside the loop outside of the if statement def undouble(given): """Finds double occurrences in given data and removes the doubling""" i = 1 while i < len(given): if given[ i ] == : del given[ i ] # remove duplicate return given You can test your result in the shell via undouble(['b','o','o','k','k','e','e','p','e','r'])

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!