On Sunday, May 31, 2015 at 4:23:19 PM UTC-7, Tim Delaney wrote:
On 1 June 2015 at 05:40, fl rxj...@gmail.com wrote:
Hi,
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
On Sunday, May 31, 2015 at 12:59:47 PM UTC-7, Denis McMahon wrote:
On Sun, 31 May 2015 12:40:19 -0700, fl wrote:
reversed returns an iterator, not a list, so it returns the reversed list
of elements one at a time. You can use list() or create a list from
reversed and then join the result:
fl writes:
On Sunday, May 31, 2015 at 12:59:47 PM UTC-7, Denis McMahon wrote:
On Sun, 31 May 2015 12:40:19 -0700, fl wrote:
reversed returns an iterator, not a list, so it returns the reversed
list of elements one at a time. You can use list() or create a list
from reversed and then join the
On Sun, 31 May 2015 12:40:19 -0700, fl 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
My questions:
1. What use for reversed(). I do not find an example on web.
2
On 1 June 2015 at 05:40, fl rxjw...@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
On Sun, 31 May 2015 12:40:19 -0700 (PDT), fl wrote:
2. If reversed() is wrong the my purpose, what method can do it? i.e. '4321'
out.
Try using slices:
b='1234'
b[::-1]
'4321'
https://docs.python.org/2/whatsnew/2.3.html#extended-slices
--
On 01/06/2015 00:23, Tim Delaney wrote:
On 1 June 2015 at 05:40, fl rxjw...@gmail.com
mailto:rxjw...@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
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
My questions:
1. What use for reversed(). I do not find an example on web.
2. If reversed() is wrong the my purpose, what method can do
On Sun, May 31, 2015 at 1:58 PM, Denis McMahon denismfmcma...@gmail.com wrote:
reversed returns an iterator, not a list, so it returns the reversed list
of elements one at a time. You can use list() or create a list from
reversed and then join the result:
$ python
Python 2.7.3 (default, Dec
On 1 June 2015 at 10:30, Mark Lawrence breamore...@yahoo.co.uk wrote:
On 01/06/2015 00:23, Tim Delaney wrote:
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
10 matches
Mail list logo