Path: csiph.com!news.swapon.de!newsreader4.netcologne.de!news.netcologne.de!bcyclone04.am1.xlned.com!bcyclone04.am1.xlned.com!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; 'constructor': 0.07; 'list?': 0.07; 'strings.': 0.07; '[1,': 0.09; 'creighton': 0.09; 'subject:into': 0.09; 'wed,': 0.15; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'received:192.168.1.4': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'skip:> 20': 0.16; 'wrote:': 0.16; 'string': 0.17; 'first.': 0.18; 'laura': 0.18; '>>>': 0.20; '2015': 0.20; 'sep': 0.22; 'header:In-Reply-To:1': 0.24; 'header :User-Agent:1': 0.26; '+0200,': 0.27; 'convert': 0.29; "i'm": 0.30; 'received:84': 0.32; 'list': 0.34; 'skip:> 10': 0.35; 'something': 0.35; 'should': 0.36; 'there': 0.36; 'to:addr:python- list': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'wanted': 0.37; 'why': 0.39; 'received:192': 0.39; 'rather': 0.39; 'to:addr:python.org': 0.40; 'your': 0.60; '>>>>>': 0.66; 'results': 0.66; 'dennis': 0.91 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=MbeRwMLf c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=EBOSESyhAAAA:8 a=IkcTkHD0fZMA:10 a=QrVWhbZvAAAA:8 a=qp0KhV_HEwHGAc3GpGYA:9 a=QEXdDO2ut3YA:10 X-AUTH: mrabarnett@:2500 Subject: Re: Python, convert an integer into an index? To: python-list@python.org References: <201509222221.t8MMLMi5015927@fido.openend.se> From: MRAB Date: Thu, 24 Sep 2015 14:30:22 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1443101432 news.xs4all.nl 23774 [2001:888:2000:d::a6]:39710 X-Complaints-To: abuse@xs4all.nl X-Received-Bytes: 3759 X-Received-Body-CRC: 720448819 Xref: csiph.com comp.lang.python:97073 On 2015-09-23 10:01, Anssi Saari wrote: > Dennis Lee Bieber writes: > >> On Wed, 23 Sep 2015 00:21:22 +0200, Laura Creighton >> declaimed the following: >> >> >>> >>>You need to convert your results into a string first. >>> >>>result_int=1234523 >>>result_list=[] >>> >>>for digit in str(result_int): >>> result_list.append(int(digit)) >>> >> >> Rather wordy... >> >>>>> [int(i) for i in str(1234523)] >> [1, 2, 3, 4, 5, 2, 3] > > I'm suprised. Why not just: > > list(str(results)) > > In other words, is there something else the list constructor should do > with a string other than convert it to a list? > The OP wanted the result to be a list of ints, not a list of strings.