As Zamyla states in this video a do while C loop can be translated to this python pseudo-code where an invalid input will re-prompt the user.
While True:
# prompt user
if condition:
break
Yet when I run say -1 through the code below it appears just ends everything rather than repeat the loop.
So the question really is how exactly break works and what am I doing wrong in python vs C?
Also why aren't floats working vs whole numbers even though I used cs50.get_float()??
Cheers!
import cs50
while True:
while True:
print ("Enter dollar amount: ", end="")
change = cs50.get_float()
if change < 0:
print ("Invalid!")
break
break
count = 0
if change <= 0.009:
change = round(change * 100)
while (change > 0):
if change >= 25:
change -= 25
count += 1
elif change >= 10:
change -= 10
count += 1
elif change >= 5:
change -= 5
count += 1
elif change >= 1:
change -= 1
count += 1
print ("count: ", count)
break