so, I need one of my variables to be A possibility. like, it is a user input var & it can be both a floating decimal point or a string. And, so I want to do stuff with it, like >/</= but if the user says "done" I exit. So, let me show you:
largest = None
smallest = None
while True:
try:
num = input("Enter a number: ")
float(num)
except:
"invalid input"
if num == "done":
break
if num > largest:
largest = num
if smallest == None:
smallest= num
if smallest > num:
smallest = num
print(num)
print("Maximum is", largest)
print("Minimum is", smallest)
Aucun commentaire:
Enregistrer un commentaire