I believe that you are trying for these :
the_array = []
while True:
sval = input('Enter a number: ')
if sval == 'done':
break
try:
ival = int(sval)
the_array.append(ival)
except:
print('Invalid input')
continue
def maximum(values):
num1 = 0
for i in values:
if i >= num1:
num1 = i
return num1
def minimum(values):
num2 = 500000000000000000000 //big number justfor reference to find the lowest
for i in values:
if i <= num2:
num2 = i
return num2
print('Maximum is', maximum(the_array))
print('Minimum is', minimum(the_array))
But you may use Built-in function
to make your program shorter and much more easier to read:
the_array = []
while True:
sval = input('Enter a number: ')
if sval == 'done':
break
try:
ival = int(sval)
the_array.append(ival)
except:
print('Invalid input')
continue
print('Maximum number :', max(the_array))
print('Minimum number :', min(the_array))
I’m not the one line
guy but this should get your work done
This is list of Built In function
Goodluck on your python journey
0
solved I am a Python noob and I cannot get the correct output for a tutorial. Can you direct me to the syntax for my function call [closed]