Q:

Getting bad max and min values from list

I used split to remove whitespaces and turn string into list and using built in function I tried to find the max and min values of the list but I gave incorrect ans also I want ans in formate " x y "where x and y are max and min respectively.
When I print list it consist of ' ' every elements of list
Thanks in Advance.
My code:
def high_and_low(numbers):
    numbers = numbers.split()
    numbers = list(numbers)
    return max(numbers),min(numbers)

print high_and_low("4 5 29 54 4 0 -214 542 -64 1 -3 6 -6")

A:

split returns strings, and you don't convert the strings to actual numbers. When comparing strings, the meaning of the comparison is different than when comparing numbers:
>>> '2' > '10'
True

So you need to change your function to something like this:
In [1]: def high_and_low(s):
   ...:     numbers = [int(x) for x in s.split()]
   ...:     return max(numbers), min(numbers)
   ...: 

In [2]: high_and_low("4 5 29 54 4 0 -214 542 -64 1 -3 6 -6")
Out[2]: (542, -214)

