[Tutor] How many times X is in a list?

2006-12-20 Thread Carlos
Hello, Can you help me with this please? I have a list that contains elements to be created (in a 3D app), in the list each element is a dictionary that contains data, like: Elements = [ {'Width': 3.0, 'Depth': 3.0, 'Name': 'Access', 'Parent': 'Plot', 'Height': 3.0}, {'

Re: [Tutor] How many times X is in a list?

2006-12-20 Thread Kent Johnson
Carlos wrote: > Hello, > > Can you help me with this please? > > I have a list that contains elements to be created (in a 3D app), in the > list each element is a dictionary that contains data, like: > > Elements = [ > {'Width': 3.0, 'Depth': 3.0, 'Name': 'Access', 'Parent': > 'Plo

Re: [Tutor] How many times X is in a list?

2006-12-20 Thread Luke Paireepinart
> Yes, count() is looking for exact matches. You can make a new list with > just the circulation names and take the length of that; something like this: > len([name for name in built_Objects if name.startswith('Circulation')]) > > or perhaps slightly more efficient (Python 2.5): > sum(1 for name

Re: [Tutor] How many times X is in a list?

2006-12-20 Thread Kent Johnson
Luke Paireepinart wrote: >> Yes, count() is looking for exact matches. You can make a new list with >> just the circulation names and take the length of that; something like this: >> len([name for name in built_Objects if name.startswith('Circulation')]) >> >> or perhaps slightly more efficient (P

Re: [Tutor] How many times X is in a list?

2006-12-20 Thread Carlos
Thanks Kent, That solves it pretty well. Carlos Kent Johnson wrote: > Yes, count() is looking for exact matches. You can make a new list > with just the circulation names and take the length of that; something > like this: > len([name for name in built_Objects if name.startswith('Circulatio