On Thu, Sep 9, 2010 at 11:34 AM, Evert Rol wrote:
> Read
> http://docs.python.org/library/stdtypes.html#sequence-types-str-unicode-list-tuple-buffer-xrange
> , note 5 (about one "page" down), which explicitly says "If i or j are
> omitted or None, they become “end” values (which end depends on the
>> But remember that you can make it simpler if you simply don't specify
>> the start and end points:
>>
> 'hello'[::-1]
>> 'olleh'
>>
>
> While I know that idiom works, I haven't really found an explanation
> as to *why* it works that way.
>
> For a string S:
> * Using range, you need ran
On Tue, Sep 7, 2010 at 1:49 PM, Roel Schroeven
wrote:
>
> But remember that you can make it simpler if you simply don't specify
> the start and end points:
>
'hello'[::-1]
> 'olleh'
>
While I know that idiom works, I haven't really found an explanation
as to *why* it works that way.
For a s
>>> Assuming that mytext is "test", I've found that mytext[-1:-4:-1]
>>> doesn't work (as I expected it to) but that mytext[::-1] does.
>>>
>>> While that's fine, I just wondered why mytext[-1:-4:-1] doesn't
>>> work?
>>
>> It does work.
>> But remember that slices give you the first item to one le
Op 2010-09-07 0:43, Alan Gauld schreef:
>
> "lists" wrote
>
>> Assuming that mytext is "test", I've found that mytext[-1:-4:-1]
>> doesn't work (as I expected it to) but that mytext[::-1] does.
>>
>> While that's fine, I just wondered why mytext[-1:-4:-1] doesn't
>> work?
>
> It does work.
> B
On Tue, Sep 7, 2010 at 12:44 AM, lists wrote:
>>> Assuming that mytext is "test", I've found that mytext[-1:-4:-1]
>>> doesn't work (as I expected it to) but that mytext[::-1] does.
>>>
>>> While that's fine, I just wondered why mytext[-1:-4:-1] doesn't work?
>>
>> How does it not "work"? What did
On Tue, 7 Sep 2010 08:14:59 am lists wrote:
> Hi guys,
>
> Continuing my Python learning, I came across an exercise which asks
> me to take a string and reverse it.
>
> I understand that there is a function to do this i.e mytext.reverse()
You understand wrong :)
There is a function reversed() whi
>>> Assuming that mytext is "test", I've found that mytext[-1:-4:-1]
>>> doesn't work (as I expected it to) but that mytext[::-1] does.
>>>
>>> While that's fine, I just wondered why mytext[-1:-4:-1] doesn't work?
>>
>> How does it not "work"? What did you expect to happen? What did it do
>> inste
>> Assuming that mytext is "test", I've found that mytext[-1:-4:-1]
>> doesn't work (as I expected it to) but that mytext[::-1] does.
>>
>> While that's fine, I just wondered why mytext[-1:-4:-1] doesn't work?
>
> How does it not "work"? What did you expect to happen? What did it do instead?
>
> Gr
"lists" wrote
Assuming that mytext is "test", I've found that mytext[-1:-4:-1]
doesn't work (as I expected it to) but that mytext[::-1] does.
While that's fine, I just wondered why mytext[-1:-4:-1] doesn't
work?
It does work.
But remember that slices give you the first item to one less
tha
On 7 September 2010 00:14, lists wrote:
> Assuming that mytext is "test", I've found that mytext[-1:-4:-1]
> doesn't work (as I expected it to) but that mytext[::-1] does.
>
> While that's fine, I just wondered why mytext[-1:-4:-1] doesn't work?
How does it not "work"? What did you expect to happ
Hi guys,
Continuing my Python learning, I came across an exercise which asks me
to take a string and reverse it.
I understand that there is a function to do this i.e mytext.reverse()
I imagine that the exercise author would rather I did this the hard
way however. ;-)
Assuming that mytext is "te
12 matches
Mail list logo