Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #97007
| Path | csiph.com!goblin1!goblin.stu.neva.ru!uio.no!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.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; 'strings.': 0.07; '[1,': 0.09; 'creighton': 0.09; 'subject:into': 0.09; 'successive': 0.09; 'python': 0.10; 'index': 0.13; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'integers,': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 'received:192.168.1.4': 0.16; 'url:tutor': 0.16; 'wrote:': 0.16; 'string': 0.17; 'first.': 0.18; 'laura': 0.18; '>>>': 0.20; '2015': 0.20; 'fairly': 0.22; 'int,': 0.22; 'sep': 0.22; 'header:In-Reply-To:1': 0.24; 'header:User- Agent:1': 0.26; 'chris': 0.26; 'back.': 0.27; 'this.': 0.28; '-0700,': 0.29; 'character': 0.29; 'convert': 0.29; 'url:mailman': 0.30; 'url:python': 0.33; 'shorter': 0.33; 'url:listinfo': 0.34; 'tue,': 0.34; 'list': 0.34; 'something': 0.35; 'but': 0.36; 'url:org': 0.36; 'assigned': 0.36; 'to:addr:python-list': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'list.': 0.37; 'wanted': 0.37; 'mailing': 0.38; 'received:192': 0.39; 'url:mail': 0.40; 'to:addr:python.org': 0.40; 'easy': 0.60; 'your': 0.60; 'back': 0.62; 'tutor': 0.66; 'results': 0.66 |
| X-CM-Score | 0.00 |
| X-CNFS-Analysis | v=2.1 cv=CvRCCSMD c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=EBOSESyhAAAA:8 a=IkcTkHD0fZMA:10 a=8AHkEIZyAAAA:8 a=Jv9h3AXjujB2Mg7vKZ0A: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> |
| From | MRAB <python@mrabarnett.plus.com> |
| Date | Wed, 23 Sep 2015 00:27:03 +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 | <201509222221.t8MMLMi5015927@fido.openend.se> |
| 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.79.1442964432.28679.python-list@python.org> (permalink) |
| Lines | 37 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1442964432 news.xs4all.nl 23769 [2001:888:2000:d::a6]:56931 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:97007 |
Show key headers only | View raw
On 2015-09-22 23:21, Laura Creighton wrote: > In a message of Tue, 22 Sep 2015 14:43:55 -0700, Chris Roberts writes: >> >> >>(How do I make it into an index? ) >>Preferably something fairly easy to understand as I am new at this. >> >>results = 134523 #(Integer) >> >>Desired: >>results = [1, 2, 3, 4, 5, 2, 3] #(INDEX) >> >>Somehow I see ways to convert index to list to int, but not back again. >> >>Thanks, >>crzzy1 > > 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)) > > digit will be assigned to successive 1 character long strings. Since > you wanted a list of integers, you have to convert it back. > > If you are learning python you may be interested in the tutor mailing > list. https://mail.python.org/mailman/listinfo/tutor > A shorter way using strings: >>> results = 134523 >>> list(map(int, str(results))) [1, 3, 4, 5, 2, 3]
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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