1 | initial version |

You should notice that the elements of `L`

are not lists, but partitions (that do not provide a `count()`

function):

```
sage: L[0]
[6]
sage: L[0].parent()
Partitions of the integer 6
sage: type(L[0])
<class 'sage.combinat.partition.Partitions_n_with_category.element_class'>
```

Of course, you can transform them as lists with the `list`

function:

```
sage: list(L[0])
[6]
sage: type(list(L[0]))
<type 'list'>
```

Hence, you can do;

```
sage: [j for j in L if list(j).count(2)>0]
[[4, 2], [3, 2, 1], [2, 2, 2], [2, 2, 1, 1], [2, 1, 1, 1, 1]]
```

But more elegantly, instead of counting, you can check that `2`

belongs to the partition with the `in`

operator:

```
sage: [j for j in L if 2 in j]
[[4, 2], [3, 2, 1], [2, 2, 2], [2, 2, 1, 1], [2, 1, 1, 1, 1]]
```

2 | No.2 Revision |

You should notice that the elements of `L`

are not lists, but partitions (that do not provide a `count()`

~~function):~~function as you saw with the `AttributeError`

):

```
sage: L[0]
[6]
sage: L[0].parent()
Partitions of the integer 6
sage: type(L[0])
<class 'sage.combinat.partition.Partitions_n_with_category.element_class'>
```

Of course, you can transform them as lists with the `list`

function:

```
sage: list(L[0])
[6]
sage: type(list(L[0]))
<type 'list'>
```

Hence, you can do;

```
sage: [j for j in L if list(j).count(2)>0]
[[4, 2], [3, 2, 1], [2, 2, 2], [2, 2, 1, 1], [2, 1, 1, 1, 1]]
```

But more elegantly, instead of counting, you can check that `2`

belongs to the partition with the `in`

operator:

```
sage: [j for j in L if 2 in j]
[[4, 2], [3, 2, 1], [2, 2, 2], [2, 2, 1, 1], [2, 1, 1, 1, 1]]
```

3 | No.3 Revision |

You should notice that the elements of `L`

are not lists, but partitions (that do not provide a `count()`

~~function ~~method as you saw with the `AttributeError`

):

```
sage: L[0]
[6]
sage: L[0].parent()
Partitions of the integer 6
sage: type(L[0])
<class 'sage.combinat.partition.Partitions_n_with_category.element_class'>
```

Of course, you can transform them as lists with the `list`

function:

```
sage: list(L[0])
[6]
sage: type(list(L[0]))
<type 'list'>
```

Hence, you can do;

```
sage: [j for j in L if list(j).count(2)>0]
[[4, 2], [3, 2, 1], [2, 2, 2], [2, 2, 1, 1], [2, 1, 1, 1, 1]]
```

But more elegantly, instead of counting, you can check that `2`

belongs to the partition with the `in`

operator:

```
sage: [j for j in L if 2 in j]
[[4, 2], [3, 2, 1], [2, 2, 2], [2, 2, 1, 1], [2, 1, 1, 1, 1]]
```

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.