Beginner Python Help
Jussi Piitulainen
jussi.piitulainen at helsinki.fi
Fri Mar 18 03:44:19 EDT 2016
Terry Reedy writes:
> On 3/18/2016 3:04 AM, Alan Gabriel wrote:
...
>> list1=(num.split())
>
> list1 is a list of strings
>
>> maxim= (max(list1))
>> minim= (min(list1))
>
> min and max compare the strings as strings, lexicographically
>
>> print(minim, maxim)
...
> You failed to convert strings of digits to ints. Try
>
> list1 = map(int, num.split)
>
> This will raise TypeError on strings that cannot be converted.
Written in a hurry? :)
Surely it'll raise something about a method not being iterable, and when
that is fixed, something about not being able to invent a minimum for an
empty sequence.
list1 = list(map(int, num.split()))
More information about the Python-list
mailing list