On Thu, 4 Jun 2015 07:08 am, Rustom Mody wrote:
> So it means that indices can give indexerror; slices cannot?
If you write your own class with a __getitem__ method, you can have it do
anything you like, including raise an exception.
Built-in sequence types like list, str and tuple, however, all
On Wed, Jun 3, 2015 at 3:08 PM, Rustom Mody wrote:
> On Tuesday, June 2, 2015 at 7:50:58 PM UTC+5:30, Ian wrote:
>> On Tue, Jun 2, 2015 at 6:35 AM, Rustom Mody wrote:
>> > For that matter even this works
>> > But I am not sure whats happening or that I like it
>> >
>> [x[-2:] for x in lines
On 03/06/2015 22:08, Rustom Mody wrote:
On Tuesday, June 2, 2015 at 7:50:58 PM UTC+5:30, Ian wrote:
On Tue, Jun 2, 2015 at 6:35 AM, Rustom Mody wrote:
For that matter even this works
But I am not sure whats happening or that I like it
[x[-2:] for x in lines]
['12', '42', '49', '56', '25',
On Tuesday, June 2, 2015 at 7:50:58 PM UTC+5:30, Ian wrote:
> On Tue, Jun 2, 2015 at 6:35 AM, Rustom Mody wrote:
> > For that matter even this works
> > But I am not sure whats happening or that I like it
> >
> [x[-2:] for x in lines]
> > ['12', '42', '49', '56', '25', '36', '49', '64', '81'
On Tue, 2 Jun 2015 10:23 pm, fl wrote:
> I don't know whether there is a way to know the length of lines[3].
The same way as to know the length of anything else:
len(x) # the length of x
len("hello") # the length of "hello"
len(lines[3]) # the length of lines[3]
> Then,
> I can use a -1 ste
On Tue, Jun 2, 2015 at 6:35 AM, Rustom Mody wrote:
> For that matter even this works
> But I am not sure whats happening or that I like it
>
[x[-2:] for x in lines]
> ['12', '42', '49', '56', '25', '36', '49', '64', '81', '00']
x[-2:] selects all items in the sequence with index i such that
On Tuesday, June 2, 2015 at 5:53:34 PM UTC+5:30, fl wrote:
> Hi,
>
> I have a list:
>
>
>
>
>
>
> >>> lines
> ['12', '42', '49', '156', '225', '36', '49', '164', '11181', '3100']
>
>
>
> I want to access the last two digits. That is:
>
> ['12', '42', '49', '56', '25', '36', '49', '64', '
fl wrote:
---snip
lines
> ['12', '42', '49', '156', '225', '36', '49', '164', '11181', '3100']
>
>
>
> I want to access the last two digits. That is:
>
> ['12', '42', '49', '56', '25', '36', '49', '64', '81', '00']
>
>
> When I try to use lines[3][0] is '1'
> lines[3][1] is '5'
> l
On Tue, Jun 2, 2015 at 8:23 AM, fl wrote:
> Hi,
>
> I have a list:
>
>
>
>
>
>
lines
> ['12', '42', '49', '156', '225', '36', '49', '164', '11181', '3100']
>
>
>
> I want to access the last two digits. That is:
>
> ['12', '42', '49', '56', '25', '36', '49', '64', '81', '00']
>
>
> When I try
Hi,
I have a list:
>>> lines
['12', '42', '49', '156', '225', '36', '49', '164', '11181', '3100']
I want to access the last two digits. That is:
['12', '42', '49', '56', '25', '36', '49', '64', '81', '00']
When I try to use lines[3][0] is '1'
lines[3][1] is '5'
lines[3][2] is '6'
I d
10 matches
Mail list logo