Question: Rewrite the following function using a while loop instead of a for loop and without using any break statements. The rewritten function must behave
Rewrite the following function using a while loop instead of a for loop and without using any break statements. The rewritten function must behave exactly the same as the original version for all possible parameter values. def blat (nums, value): """Does something weird""" stuff = [] for num in nums: if num % value == 0: stuff.append(num // value) Test else: stuff.append(num) return stuff For example: Result print (blat([1, 5, 10, 12, 14], 5)) [1, 1, 2, 12, 14]
Step by Step Solution
There are 3 Steps involved in it
Doing same program with while loop def blatn... View full answer
Get step-by-step solutions from verified subject matter experts
