Here is my code. I am trying to find both the small and large number in a series of entered numbers. It seems like the code only works for either small or large but not both…can anybody point me to what I am doing wrong? This is my first python program…Thank you!
sval = None
lval = None
while True :
inp = input('Enter a number: ')
if inp == 'done' :
break
#inp = float (inp)
if sval is None and lval is None:
sval = inp
print ('sval value', sval)
lval = inp
print ('lval value', lval)
if inp < sval and > lval:
sval = inp
print ('the value of sval',sval)
if inp > lval:
lval = inp
print ('the value of lval', lval)
#if lval is None:
#lval = inp
#if inp > lval:
# lval = inp
#if inp == 'done' :
# break
#if sval > inp:
# sval = inp
#elif lval < inp:
#lval = inp
try:
inp = float(inp)
except:
print('Invalid input')
continue
# num = num + 1
#tot = tot + fval
#print ('All Done')
print ('Invalid input')
print ('Maximum is', lval)
print ('Minimum is',sval)