In <8c0a3ea9-2560-47eb-a9c7-3770e41fe...@googlegroups.com>
subhabangal...@gmail.com writes:
> Dear Group,
> I have a list of the following pattern,
> [("''", "''"), ('Eastern', 'NNP'), ('Army', 'NNP'), ('Commander', 'NNP'), (=
> 'Lt', 'NNP'), ('Gen', 'NNP'), ('Dalbir', 'NNP'), ('Singh', 'NNP'),
On 2012-12-02, Thomas Bach wrote:
> On Sun, Dec 02, 2012 at 04:16:01PM +0100, Lutz Horn wrote:
>>
>> len([x for x in l if x[1] == 'VBD'])
>>
>
> Another way is
>
> sum(1 for x in l if x[1] == 'VBD')
>
> which saves the list creation.
To also index them:
vbdix = [i for i, a in emumerate(l) if a
On Sunday, December 2, 2012 9:29:22 PM UTC+5:30, Thomas Bach wrote:
> On Sun, Dec 02, 2012 at 04:16:01PM +0100, Lutz Horn wrote:
>
> >
>
> > len([x for x in l if x[1] == 'VBD'])
>
> >
>
>
>
> Another way is
>
>
>
> sum(1 for x in l if x[1] == 'VBD')
>
>
>
> which saves the list creati
On Sun, Dec 02, 2012 at 04:16:01PM +0100, Lutz Horn wrote:
>
> len([x for x in l if x[1] == 'VBD'])
>
Another way is
sum(1 for x in l if x[1] == 'VBD')
which saves the list creation.
Regards,
Thomas.
--
http://mail.python.org/mailman/listinfo/python-list
Him
Am 02.12.2012 um 16:03 schrieb subhabangal...@gmail.com:
> I have a list of the following pattern,
>
> [("''", "''"), ('Eastern', 'NNP'), ('Army', 'NNP'), ('Commander', 'NNP'),
> ('Lt', 'NNP'), ('Gen', 'NNP'), ('Dalbir', 'NNP'), ('Singh', 'NNP'), ('Suhag',
> 'NNP'), ('briefed', 'VBD'), ('th
On Mon, Sep 24, 2012 at 10:56 AM, Littlefield, Tyler
wrote:
> I've not been following this thread fully, but why not just use x=list(y) to
> copy the list?
> The issue is that when you assign i=[1,2,3] and then j = i, j is just a
> reference to i, which is why you change either and the other chang
On 9/23/2012 3:44 PM, jimbo1qaz wrote:
On Sunday, September 23, 2012 2:31:48 PM UTC-7, jimbo1qaz wrote:
I have a nested list. Whenever I make a copy of the list, changes in one affect
the other, even when I use list(orig) or even copy the sublists one by one. I
have to manually copy each cell
On Sunday, September 23, 2012 2:31:48 PM UTC-7, jimbo1qaz wrote:
> I have a nested list. Whenever I make a copy of the list, changes in one
> affect the other, even when I use list(orig) or even copy the sublists one by
> one. I have to manually copy each cell over for it to work.
>
> Link to br
On Sun, 23 Sep 2012 14:31:48 -0700, jimbo1qaz wrote:
> I have a nested list. Whenever I make a copy of the list, changes in one
> affect the other,
Then you aren't making a copy.
py> first_list = [1, 2, 3]
py> second_list = first_list # THIS IS NOT A COPY
py> second_list.append()
py> print
On 09/23/2012 05:44 PM, jimbo1qaz wrote:
> On Sunday, September 23, 2012 2:31:48 PM UTC-7, jimbo1qaz wrote:
>> I have a nested list. Whenever I make a copy of the list, changes in one
>> affect the other, even when I use list(orig) or even copy the sublists one
>> by one. I have to manually copy
On Mon, Sep 24, 2012 at 7:44 AM, jimbo1qaz wrote:
> On Sunday, September 23, 2012 2:31:48 PM UTC-7, jimbo1qaz wrote:
>> I have a nested list. Whenever I make a copy of the list, changes in one
>> affect the other, even when I use list(orig) or even copy the sublists one
>> by one. I have to manu
On 23 September 2012 22:31, jimbo1qaz wrote:
> I have a nested list. Whenever I make a copy of the list, changes in one
> affect the other, even when I use list(orig) or even copy the sublists one
> by one. I have to manually copy each cell over for it to work.
> Link to broken code: http://jimbo
On Sunday, September 23, 2012 2:31:48 PM UTC-7, jimbo1qaz wrote:
> I have a nested list. Whenever I make a copy of the list, changes in one
> affect the other, even when I use list(orig) or even copy the sublists one by
> one. I have to manually copy each cell over for it to work.
>
> Link to br
On Thu, Sep 30, 2010 at 3:20 AM, Rog wrote:
> On Wed, 29 Sep 2010 05:52:32 -0700, bruno.desthuilli...@gmail.com wrote:
>
> > On 29 sep, 14:17, Steven D'Aprano >
> > wrote:
> >> On Tue, 28 Sep 2010 20:11:51 +0100, Rog wrote:
> >> > On Tue, 28 Sep 2010 11:59:08 -0700, geremy condra wrote:
> >>
> >
On Wed, 29 Sep 2010 05:52:32 -0700, bruno.desthuilli...@gmail.com wrote:
> On 29 sep, 14:17, Steven D'Aprano
> wrote:
>> On Tue, 28 Sep 2010 20:11:51 +0100, Rog wrote:
>> > On Tue, 28 Sep 2010 11:59:08 -0700, geremy condra wrote:
>>
>> >> On Tue, Sep 28, 2010 at 11:44 AM, Rog wrote:
>> >>> Hi al
On 29 sep, 14:17, Steven D'Aprano wrote:
> On Tue, 28 Sep 2010 20:11:51 +0100, Rog wrote:
> > On Tue, 28 Sep 2010 11:59:08 -0700, geremy condra wrote:
>
> >> On Tue, Sep 28, 2010 at 11:44 AM, Rog wrote:
> >>> Hi all,
> >>> Have been grappling with a list problem for hours... a = [2, 3, 4,
> >>> 5
On Tue, 28 Sep 2010 20:11:51 +0100, Rog wrote:
> On Tue, 28 Sep 2010 11:59:08 -0700, geremy condra wrote:
>
>> On Tue, Sep 28, 2010 at 11:44 AM, Rog wrote:
>>> Hi all,
>>> Have been grappling with a list problem for hours... a = [2, 3, 4,
>>> 5,.]
>>> b = [4, 8, 2, 6,.]
>>> Basicly I am
On Wed, Sep 29, 2010 at 1:15 AM, rog wrote:
> Shashwat Anand wrote:
>
>
>>
>> On Wed, Sep 29, 2010 at 12:14 AM, Rog > r...@pynguins.com>> wrote:
>>
>>Hi all,
>>Have been grappling with a list problem for hours...
>>a = [2, 3, 4, 5,.]
>>b = [4, 8, 2, 6,.]
>>Basicly I am
On Tue, 28 Sep 2010 11:59:08 -0700, geremy condra wrote:
> On Tue, Sep 28, 2010 at 11:44 AM, Rog wrote:
>> Hi all,
>> Have been grappling with a list problem for hours... a = [2, 3, 4,
>> 5,.]
>> b = [4, 8, 2, 6,.]
>> Basicly I am trying to place a[0], b[0] in a seperate list IF a[2] and
On Tue, Sep 28, 2010 at 11:44 AM, Rog wrote:
> Hi all,
> Have been grappling with a list problem for hours...
> a = [2, 3, 4, 5,.]
> b = [4, 8, 2, 6,.]
> Basicly I am trying to place a[0], b[0] in a seperate list
> IF a[2] and b[2] is present.
> I have tried sets, zip etc with no success.
On Wed, Sep 29, 2010 at 12:14 AM, Rog wrote:
> Hi all,
> Have been grappling with a list problem for hours...
> a = [2, 3, 4, 5,.]
> b = [4, 8, 2, 6,.]
> Basicly I am trying to place a[0], b[0] in a seperate list
> IF a[2] and b[2] is present.
>
You are not exactly clear with your proble
On Tue, 09 Dec 2008 21:40:08 -0800, dongzhi wrote:
> I have one problem for List. Like that:
>
> format='just "a" ""little"" test'
> part = format.split('"')
> print part
>
> the result is : ['just ', 'a', ' ', '', 'little', '', ' test']
>
> the list part have 7 element.
>
> If I execute part[
On Dec 10, 2:00 pm, "James Mills" <[EMAIL PROTECTED]>
wrote:
> On Wed, Dec 10, 2008 at 3:40 PM, dongzhi <[EMAIL PROTECTED]> wrote:
> > If I execute part[1], I have got 'a'. If I execute part[2], I have
> > got ' '. But, if I execute part[1::2], I have got ['a', '', '']. I
> > don't know why. Pleas
On Wed, Dec 10, 2008 at 3:40 PM, dongzhi <[EMAIL PROTECTED]> wrote:
> If I execute part[1], I have got 'a'. If I execute part[2], I have
> got ' '. But, if I execute part[1::2], I have got ['a', '', '']. I
> don't know why. Please tell me why.
Perhaps you meant:
part[1:2]
pydoc list
This will
Alan Bromborsky wrote:
> I wish to create a list of empty lists and then put something in one of
> the empty lists. Below is what I tried, but instead of appending 1 to
> a[2] it was appended to all the sub-lists in a. What am I doing wrong?
>
> a = 6*[[]]
> >>> a
> [[], [], [], [], [], []]
>
[EMAIL PROTECTED] wrote:
> For example i write the following code in the Python command line;
>
list = ['One,Two,Three,Four']
>
> Then enter this command, which will then return the following;
>
> ['One,Two,Three,Four']
This is already wrong. Assignments do not return anything.
Georg
--
h
[EMAIL PROTECTED] wrote:
> For example i write the following code in the Python command line;
>
list = ['One,Two,Three,Four']
>
> Then enter this command, which will then return the following;
>
> ['One,Two,Three,Four']
>
>
> Now the problem, reading through the Python tutorial's, it desc
[EMAIL PROTECTED] wrote:
> For example i write the following code in the Python command line;
>
list = ['One,Two,Three,Four']
>
> Then enter this command, which will then return the following;
>
> ['One,Two,Three,Four']
>
>
> Now the problem, reading through the Python tutorial's, it des
Thank you all for the replies, i now have a better solution.
Cheers
--
http://mail.python.org/mailman/listinfo/python-list
"placid" <[EMAIL PROTECTED]> writes:
> >>> list1 = [ ' XXX1', 'XXX2', 'XXX3', 'XXX5']
>
> the second list contains strings that are identical to the first list,
> so lets say the second list contains the following
>
> >>> list1 = [ ' XXX1', 'XXX2', 'XXX3', 'XXX6']
I think you meant list2 for the
Gerard Flanagan wrote:
> placid wrote:
> > Hi all,
> >
> > I have two lists that contain strings in the form string + number for
> > example
> >
> > >>> list1 = [ ' XXX1', 'XXX2', 'XXX3', 'XXX5']
> >
> > the second list contains strings that are identical to the first list,
> > so lets say the sec
placid wrote:
> Hi all,
>
> I have two lists that contain strings in the form string + number for
> example
>
> >>> list1 = [ ' XXX1', 'XXX2', 'XXX3', 'XXX5']
>
> the second list contains strings that are identical to the first list,
> so lets say the second list contains the following
>
> >>> lis
placid wrote:
>
> But there may be other characters before XXX (which XXX is constant). A
> better example would be, that string s is like a file name and the
> characters before it are the absolute path, where the strings in the
> first list can have a different absolute path then the second list
placid wrote:
> Hi all,
>
> I have two lists that contain strings in the form string + number for
> example
>
> >>> list1 = [ ' XXX1', 'XXX2', 'XXX3', 'XXX5']
>
> the second list contains strings that are identical to the first list,
> so lets say the second list contains the following
>
> >>> lis
placid:
This may be a solution:
l1 = ['acXXX1', 'XXX2', 'wXXX3', 'kXXX5']
l2 = [ 'bXXX1', 'xXXX2', 'efXXX3', 'yXXX6', 'zZZZ9']
import re
findnum = re.compile(r"[0-9]+$")
s1 = set(int(findnum.search(el).group()) for el in l1)
s2 = set(int(findnum.search(el).group()) for el in l2)
nmax = max(max(s
placid wrote:
> Simon Forman wrote:
> > placid wrote:
> > > Hi all,
> > >
> > > I have two lists that contain strings in the form string + number for
> > > example
> > >
> > > >>> list1 = [ ' XXX1', 'XXX2', 'XXX3', 'XXX5']
> > >
> > > the second list contains strings that are identical to the first
Simon Forman wrote:
> placid wrote:
> > Hi all,
> >
> > I have two lists that contain strings in the form string + number for
> > example
> >
> > >>> list1 = [ ' XXX1', 'XXX2', 'XXX3', 'XXX5']
> >
> > the second list contains strings that are identical to the first list,
> > so lets say the second
Simon Forman wrote:
> Finally, you can say:
>
> for i in xrange(1,10):
> s = "XXX1%04i" % i
> if s not in list1 and s not in list2:
> print s
>
> HTH,
> ~Simon
D'oh! Forgot to break.
for i in xrange(1,10):
s = "XXX1%04i" % i
if s not in list1 and s not in list2:
p
placid wrote:
> Hi all,
>
> I have two lists that contain strings in the form string + number for
> example
>
> >>> list1 = [ ' XXX1', 'XXX2', 'XXX3', 'XXX5']
>
> the second list contains strings that are identical to the first list,
> so lets say the second list contains the following
>
> >>> list
Thanks very much. Deepcopy works fine, as does reversed(b). I thought I
needed the index number but I didn't.
Duncan Booth wrote:
> manstey wrote:
>
> > for index in reversed(range(0,len(a)-1)):
> >if '75' in b[index][1]:
> > b[index][1].remove('75')
> > b[index][1].append('99')
manstey wrote:
> for index in reversed(range(0,len(a)-1)):
>if '75' in b[index][1]:
> b[index][1].remove('75')
> b[index][1].append('99')
>
What on earth is all that messing around in the for loop intended to do? If
you want a range from len(a)-2 to 0 inclusive then just do it i
Hi,
if u check the id's of a and b lists and also its elements, you will
obeserve that the id's of a and b have changed but id's of their
elements have not changed.
If you make a deep copy of the list a and then make your changes in
that list, it shud work. this can be done using the copy module
42 matches
Mail list logo