Re[2]: подсчитать количество определённых элементов в dict
От: 13akaEagle Россия  
Дата: 29.08.11 07:06
Оценка:
Здравствуйте, kmmbvnr, Вы писали:

K>Здравствуйте, 13akaEagle, Вы писали:


E>># а как можно ещё. локаничнее и с лябдой



K>
K>sum(1 for item in container if item.type == 'first')
K>


Sums start and the items of an iterable from left to right and returns the total. start defaults to 0. The iterable‘s items are normally numbers, and are not allowed to be strings. The fast, correct way to concatenate a sequence of strings is by calling ''.join(sequence). Note that sum(range(n), m) is equivalent to reduce(operator.add, range(n), m) To add floating point values with extended precision, see math.fsum().


А зачем там 1? Поясните пожалуйста. И что в итоге должно получиться?
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.