#How to I make the result to be like the example
19 messages · Page 1 of 1 (latest)
I would like to get minimum: -10
minimum: 8
but What Ive got is
minimum :
-10
maximum :
8
well that's cuz you put "maximum" in the last print statement
I tried sth like print(‘ maximum : ’ + max_value(maxmin)) and it didn’t work Im so confuse
Replace maximum with minimum
I tried but it didnt work. did I do anything wrong?
Gimme few mins
If the only problem is the error, read the error!
Sorry but I’m kinda new at this I don’t rrly understand TT
You cannot concatenate strings and numbers. An easy fix here is replacing the plus sign with a colon.
One sec
def max_value(list):
max = list[0]
for i in list:
if i > max:
max = i
return max
def min_value(list):
min = list[0]
for i in list:
if i < min:
min = i
return min
maxmin = ([2,3,-2,4,-7,8,-10])
print('minimum', min_value(maxmin))
print('maximum', max_value(maxmin))
no problem
If you are interested, how the print function works. You can read this: https://cs.stanford.edu/people/nick/py/python-print.html