On Fri, Jun 15, 2018 at 04:57:47PM +0300, kenneth yashim wrote:
> please im new to python or any other programming language. please i want to
> understand how slicing works
>
> [start,stop,step]
>
> >>> 'abc'[0:3]
> 'abc'
>
> >>>'abc'[0:-1]
> 'ab'
>
> why does 'abc'[2:1] or 'abc'[2:1] prin
On 15/06/18 14:57, kenneth yashim wrote:
> please im new to python or any other programming language. please i want to
> understand how slicing works
>
> [start,stop,step]
>
'abc'[0:3]
> 'abc'
>
'abc'[0:-1]
> 'ab'
>
> why does 'abc'[2:1] or 'abc'[2:1] print ' ' instead of 'c'???
Thanks to all for your answers, especially those that went into detail about
why its done in that way.
As far as whether this is actually addressed in the book, as far as I can
tell by going a few pages forward, it does not. In fact, after the code
there's a how it works section which only added t
So, in essence, that would be redefining(in Python) basic division of
grammatical structures(splices)?
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
John Russell wrote:
So, my question is this, and I realize that this is *very* basic - what is
going on with the last element? Why is it returning one less than I think it
logically should. Am I missing something here? There is not much of an
explanation in the book, but I would really like to u
On Sat, Dec 11, 2010 at 5:25 PM, John Russell wrote:
> Last night I started working through a book (Beginning Python: Using Python
> 2.6 and Python 3.1) I bought to learn Python, and there is an example in it
> that doesn't make sense to me.
> There is an example on slicing sequences that goes li
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
Luis N said unto the world upon 02/07/2005 07:51:
> On 7/2/05, Luis N <[EMAIL PROTECTED]> wrote:
>
> Umm, sorry, I meant:
>
> d[desc[x]] = exec("""'vw[%s].desc[%s]'""" % (r,x ))
>
>
>
>
>
> __
On 7/2/05, Luis N <[EMAIL PROTECTED]> wrote:
Umm, sorry, I meant:
d[desc[x]] = exec("""'vw[%s].desc[%s]'""" % (r,x ))
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Hi,
Yes, sorry I haven't posted to the list in a while. I should have been
more specific. I'm writing a simple contact database, using metakit as
the backend. Thank you for pointing out that what I was trying to do
was easier than I believed.
Here's some code.
db = metakit.storage('c:/addy.mk'
Reed L. O'Brien wrote:
>Luis N wrote:
>
>
>
>>Hi,
>>
>>
>>
>l
>
>
>>[{'last': 'Bar', 'first': 'Foo'}, {'last': 'Bar', 'first': 'Foo'},
>>{'last': 'Bar', 'first': 'Foo'}, {'last': 'Bar', 'first': 'Foo'}]
>>
>>
>>This is how I imagine it:
>>
>>for i in l:
>>for j in l
Luis N wrote:
> Hi,
>
> >>> l
> [{'last': 'Bar', 'first': 'Foo'}, {'last': 'Bar', 'first': 'Foo'},
> {'last': 'Bar', 'first': 'Foo'}, {'last': 'Bar', 'first': 'Foo'}]
>
>
> This is how I imagine it:
>
> for i in l:
> for j in l[i]:
> for k in l[i][j]:
> print k.get('first')
Luis N said unto the world upon 28/06/2005 15:25:
> Hi,
>
>
l
>
> [{'last': 'Bar', 'first': 'Foo'}, {'last': 'Bar', 'first': 'Foo'}, {'last':
> 'Bar', 'first': 'Foo'}, {'last': 'Bar', 'first': 'Foo'}]
>
>
> This is how I imagine it:
>
> for i in l:
> for j in l[i]:
> for k in l[i][j]:
>
23 matches
Mail list logo