Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #97073

Re: Python, convert an integer into an index?

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 <python@mrabarnett.plus.com>
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 <e6e800a2-a64c-47dc-87b3-c6d32b6fca2f@googlegroups.com> <201509222221.t8MMLMi5015927@fido.openend.se> <mailman.87.1442977993.28679.python-list@python.org> <vg3pp18x8e6.fsf@coffee.modeemi.fi>
From MRAB <python@mrabarnett.plus.com>
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 <vg3pp18x8e6.fsf@coffee.modeemi.fi>
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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.125.1443101432.28679.python-list@python.org> (permalink)
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

Show key headers only | View raw


On 2015-09-23 10:01, Anssi Saari wrote:
> Dennis Lee Bieber <wlfraed@ix.netcom.com> writes:
>
>> On Wed, 23 Sep 2015 00:21:22 +0200, Laura Creighton <lac@openend.se>
>> 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... <G>
>>
>>>>> [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.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Python, convert an integer into an index? Chris Roberts <thecjguy1@gmail.com> - 2015-09-22 14:43 -0700
  Re: Python, convert an integer into an index? Laura Creighton <lac@openend.se> - 2015-09-23 00:21 +0200
  Re: Python, convert an integer into an index? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-09-23 00:23 +0100
  Re: Python, convert an integer into an index? MRAB <python@mrabarnett.plus.com> - 2015-09-23 00:27 +0100
    Re: Python, convert an integer into an index? marco.nawijn@colosso.nl - 2015-09-22 23:55 -0700
  Re: Python, convert an integer into an index? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-09-22 23:13 -0400
    Re: Python, convert an integer into an index? Anssi Saari <as@sci.fi> - 2015-09-23 12:01 +0300
      Re: Python, convert an integer into an index? MRAB <python@mrabarnett.plus.com> - 2015-09-24 14:30 +0100
      Re: Python, convert an integer into an index? jmp <jeanmichel@sequans.com> - 2015-09-24 16:14 +0200
      Re: Python, convert an integer into an index? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-09-24 21:26 -0400
  Re: Python, convert an integer into an index? Denis McMahon <denismfmcmahon@gmail.com> - 2015-09-23 15:32 +0000
    Re: Python, convert an integer into an index? Lorenzo Sutton <lorenzofsutton@gmail.com> - 2015-09-24 18:13 +0200
  Re: Python, convert an integer into an index? Tim Daneliuk <tundra@bogus-city.tundraware.com> - 2015-09-23 10:55 -0500

csiph-web