Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Jussi Piitulainen Newsgroups: comp.lang.python Subject: Re: Beginner Python Help Date: Fri, 18 Mar 2016 09:44:19 +0200 Organization: A noiseless patient Spider Lines: 32 Message-ID: References: <101edd27-17e1-497c-a60f-fa56b033563b@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="305c68510616a2e7ac08bcd2ff1598bd"; logging-data="27853"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18fF1HXuinEtXr9mw1sKHKHk+PfxFdYtIA=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:bsB+SrA+NqzjYb2KB/kFul3RI+M= sha1:94ygbLTiETm7NskBIIAnkMWQDQw= Xref: csiph.com comp.lang.python:105187 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()))