python: get lowest value


I want to find out which is the lowest value and thought I could sort a list and then get the first value of the list. But somehow the sort() does not work.

str1 = '30.4'
str2 = '10.22'
str3 = '2.87'
list = [str1, str2, str3]
lowest_value = list[0]

Does anybody know why? Or even has a better solution to find out the lowest string number? Thanks in advance

.lower returns the lowercase version of a string.
You want to use the min function.

smallest_value = min([1, 4, 8]) # Returns 1

hey thanks a lot for that but still I get 10.22 as the lowest instead of 2.87. I assume because it counts only the first number.

But how can I prevent that?

aha I changed the strings to floats and now it works. Thanks again for that