Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Terry Reedy Newsgroups: comp.lang.python Subject: Re: Beginner Python Help Date: Fri, 18 Mar 2016 03:20:49 -0400 Lines: 38 Message-ID: References: <101edd27-17e1-497c-a60f-fa56b033563b@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de iYbbT4brOZUePO0FkV2CrAM48FLhrrW6yR/+Q4qt7+Lw== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:Help': 0.10; 'python': 0.10; 'jan': 0.11; 'code?': 0.16; 'list1': 0.16; 'map(int,': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'reedy': 0.16; 'wrote:': 0.16; 'string': 0.17; 'input': 0.18; 'hey': 0.20; 'trying': 0.22; 'am,': 0.23; 'header:In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; '(e.g.': 0.27; 'compare': 0.27; 'alan': 0.29; 'strings,': 0.29; 'convert': 0.29; 'raise': 0.29; 'problem': 0.33; 'list': 0.34; 'done': 0.35; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'there,': 0.37; 'received:org': 0.37; 'doing': 0.38; 'wrong': 0.38; 'to:addr:python.org': 0.40; 'where': 0.40; 'maximum': 0.61; 'skip:n 10': 0.62; 'received:96': 0.63; 'gabriel': 0.84; 'min': 0.91; 'received:fios.verizon.net': 0.91 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: pool-96-227-207-81.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 In-Reply-To: <101edd27-17e1-497c-a60f-fa56b033563b@googlegroups.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:105184 On 3/18/2016 3:04 AM, Alan Gabriel wrote: > Hey there, > > I just started out python and I was doing a activity > where im trying to find the max and min of a list of numbers i inputted. > > This is my code.. > > num=input("Enter list of numbers") input returns a string > 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) > > So the problem is that when I enter numbers with an uneven > amount of digits (e.g. I enter 400 20 36 85 100) > I do not get 400 as the maximum nor 20 as the minimum. > What have I done wrong in the code? 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. -- Terry Jan Reedy