python - finding highest number, no arrays, only if statements -
i taking course in python programming , have been given assignment complete of finding highest number given prompting user. easy complete array unable use them assignment. having issue if input series of numbers such "55, 100, 99" program telling 99 highest number. not sure going wrong.
largest = none smallest = none temp = none while temp != "done": num = raw_input("enter number: ") if num == "done" : break try: int(num) except: print ('that not integer. try again') break print(largest) if largest none: largest = num if largest != none , num > largest: largest = num print ('invalid input') print "maximum is", largest print "minimum is", smallest
change:
int(num)
to:
num = int(num)
otherwise, num
still string because you're not saving result of conversion anywhere.
Comments
Post a Comment