On 01/13/2013 07:45 AM, subhabangal...@gmail.com wrote:
Dear Group,
I have a list like,
list1=[1,2,3,4,5,6,7,8,9,10,11,12]
Now, if I want to take a slice of it, I can.
It may be done in,
list2=list1[:3]
print list2
[1, 2, 3]
If I want to iterate the list, I may do as,
for i in list1:
On 01/13/13 07:48, Boris FELD wrote:
2013/1/13 Tim Chase :
SIZE = 3
for i in range(len(list1)//SICE):
... print list1[i*SIZE:i*SIZE+SIZE]
A little shorter and simpler version:
x = x[1:]
for i in range(0,len(x),SIZE):
... print x[i: i+SIZE]
Doh, I always forget that range() takes
2013/1/13 Tim Chase :
> On 01/13/13 06:45, subhabangal...@gmail.com wrote:
>
SIZE = 3
for i in range(len(list1)//SICE):
> ... print list1[i*SIZE:i*SIZE+SIZE]
> ...
> [1, 2, 3]
> [4, 5, 6]
> [7, 8, 9]
> [10, 11, 12]
>
A little shorter and simpler version:
>>> x = x[1:]
>>> for i in ra
On 01/13/13 06:45, subhabangal...@gmail.com wrote:
Dear Group,
I have a list like,
list1=[1,2,3,4,5,6,7,8,9,10,11,12]
Now, if I want to take a slice of it, I can.
It may be done in,
list2=list1[:3]
print list2
[snip]
Now, I want to combine iterator with a slicing condition like
for i=li
On 01/13/2013 07:45 AM, subhabangal...@gmail.com wrote:
> Dear Group,
>
> I have a list like,
>
list1=[1,2,3,4,5,6,7,8,9,10,11,12]
What version of Python?
> Now, if I want to take a slice of it, I can.
> It may be done in,
list2=list1[:3]
print list2
> [1, 2, 3]
>
> If I want to it
Dear Group,
I have a list like,
>>> list1=[1,2,3,4,5,6,7,8,9,10,11,12]
Now, if I want to take a slice of it, I can.
It may be done in,
>>> list2=list1[:3]
>>> print list2
[1, 2, 3]
If I want to iterate the list, I may do as,
>>> for i in list1:
print "Iterated Value Is:",i
It