0
I wanna end the while loop when the user enters a value that is not either a float or integer. Why doesnât this code work?
2 Answers
+ 5
input() returns string by default. So, type() always gives string type.
You may try using try-except statements to handle this issue.
+ 1
question=input("Yes or no: ")
if question.upper()== "YES":
while True:
ans=input("What other number")
if not ans.replace('.', '').isdigit():
break