Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #91599
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <timothy.c.delaney@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.017 |
| X-Spam-Evidence | '*H*': 0.97; '*S*': 0.00; 'string.': 0.04; 'error:': 0.05; 'python': 0.11; 'syntax': 0.13; 'output': 0.15; 'iterator': 0.16; 'run:': 0.16; 'syntaxerror:': 0.16; 'wrote:': 0.16; 'string': 0.17; 'copied': 0.18; 'version.': 0.18; 'language': 0.19; 'email addr:gmail.com>': 0.20; '(on': 0.22; 'assuming': 0.22; '2015': 0.23; 'specified': 0.23; 'header:In-Reply-To:1': 0.24; 'tim': 0.24; 'message-id:@mail.gmail.com': 0.28; 'coded': 0.29; 'colon': 0.29; 'e.g.': 0.31; 'to:name:python-list': 0.31; 'print': 0.31; 'url:python': 0.33; 'subject:use': 0.33; 'received:google.com': 0.34; 'to:addr:python-list': 0.35; 'something': 0.35; 'but': 0.36; 'url:org': 0.36; 'statement': 0.36; 'hi,': 0.37; 'subject:: ': 0.37; 'end': 0.39; 'means': 0.39; 'url:2': 0.39; 'does': 0.39; 'url:docs': 0.39; 'to:addr:python.org': 0.39; 'url:3': 0.60; 'back': 0.61; 'hope': 0.61; 'per': 0.61; 'above,': 0.63; 'complete': 0.63; 'delaney': 0.84; 'url:tutorial': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=AFqgsj51IRIgX+cWhDLXyuFtTP7Bvej9f6mRL+S4MCc=; b=1C/tPFN4T0pidI0J75NB8WMYJBpFGy1khphA0m7cslqU+F84wiae/ZfwmLirX8s9oN +nuWF9EZ/R2QTevncCOdV/7lG8ZYh/Yg1pc/aknhTSy7gio73TnXP6+0dN5K6Wd8+NY/ m0A+GqdJB8V2tjJo+PAlDUL4N1PXkFTD/MD1I5k/s5NOy1GE+aicU5Q7zdBrS576ns++ g/AKy0dZHhtTUQng4ZVecCRwR9EStAGMZugCS5npPaO6igI1aS3s4yLZSziW3vgABbH9 gzPjF5gBX4U3BU/2s5gChpnxkiCvLrnUarKGgM4CmPj0zPxRbPTWlI6zvQXg6x9C/Ev1 XIiw== |
| MIME-Version | 1.0 |
| X-Received | by 10.181.11.137 with SMTP id ei9mr15067016wid.48.1433114582240; Sun, 31 May 2015 16:23:02 -0700 (PDT) |
| In-Reply-To | <514c05fc-dded-4278-ac86-3e8e3cd0e851@googlegroups.com> |
| References | <514c05fc-dded-4278-ac86-3e8e3cd0e851@googlegroups.com> |
| Date | Mon, 1 Jun 2015 09:23:02 +1000 |
| Subject | Re: What use for reversed()? |
| From | Tim Delaney <timothy.c.delaney@gmail.com> |
| To | Python-List <python-list@python.org> |
| Content-Type | multipart/alternative; boundary=f46d043892d798d2ff051768fd78 |
| 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.252.1433114589.5151.python-list@python.org> (permalink) |
| Lines | 80 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1433114589 news.xs4all.nl 2845 [2001:888:2000:d::a6]:35845 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:91599 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
On 1 June 2015 at 05:40, fl <rxjwg98@gmail.com> wrote:
> Hi,
>
> I have a string b='1234'. I run: br=reversed(b)
>
> I hope that I can print out '4321' by:
>
> for br in b
>
> but it complains:
> SyntaxError: invalid syntax
>
Any time you get a SyntaxError, it means that you have coded something
which does not match the specified syntax of the language version.
Assuming you copied and pasted the above, I can see an error:
for br in b
The for statement must have a colon at the end of line e.g. a complete for
statement and block is:
for br in b:
print br
This will output the characters one per line (on Python 3.x), since that is
what the reversed() iterator will return. You will need to do something
else to get it back to a single string.
Have you read through the python tutorials?
https://docs.python.org/3/tutorial/
or for Python 2.x:
https://docs.python.org/2/tutorial/
Tim Delaney
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
What use for reversed()? fl <rxjwg98@gmail.com> - 2015-05-31 12:40 -0700
Re: What use for reversed()? Denis McMahon <denismfmcmahon@gmail.com> - 2015-05-31 19:58 +0000
Re: What use for reversed()? Ian Kelly <ian.g.kelly@gmail.com> - 2015-05-31 18:06 -0600
Re: What use for reversed()? cheshire <supportNOSPAM@microsoft.com> - 2015-05-31 23:26 +0200
Re: What use for reversed()? Tim Delaney <timothy.c.delaney@gmail.com> - 2015-06-01 09:23 +1000
Re: What use for reversed()? fl <rxjwg98@gmail.com> - 2015-05-31 20:11 -0700
Re: What use for reversed()? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-06-01 01:30 +0100
Re: What use for reversed()? Tim Delaney <timothy.c.delaney@gmail.com> - 2015-06-01 13:59 +1000
Re: What use for reversed()? fl <rxjwg98@gmail.com> - 2015-05-31 22:15 -0700
Re: What use for reversed()? Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2015-06-01 09:11 +0300
csiph-web