Python Loops: Medical Insurance Project Extra Task (Convert for loop to a while loop)

Hello guys, nice to meet you all.

Here I have a question about how to convert a for loop to a while loop in this exercise.

Here is the for loop:
for insurance_cost in actual_insurance_costs:
total_cost += insurance_cost

New to programming, please don’t mind if I’m asking stupid questions!

Cheers and happy coding :slight_smile: Have a nice holiday!

Hello @patricio42, welcome to the forums! In this case, you would need to create a counter hint, hint variable to iterate through the list. You’d then have to use this variable to get each item from the array, then finally do something to the variable to stop the loop being infinite. I hope this has given you some ideas!

1 Like