I'm new in Python and doing an online tutorial. I have an assignment that I can not accomplish. My problem is that when I run this code, the minimum
variable stays the same to None
and does not record the new value input.
maximum = None
minimum = None
while True:
try:
num2 = raw_input('Type here ')
if num2 == 'done':break
else:
num = int(num2)
if num <= minimum:
minimum = num
print minimum
elif num >= maximum:
maximum = num
print maximum
except:
print 'Invalid Entry'
print 'Maximum is %d' % maximum
print 'Minimum is %d' % minimum
Aucun commentaire:
Enregistrer un commentaire