# Why does the code not work?

Hi, I wanted to use a program from an older question from myself again and found the following strange thing:

The following code works fine:

```
m=3
le_relations = lambda P: [(a,b) if P.le(a,b) else (b,a) for a,b in P.comparability_graph().edges(labels=None)]
cover_relations = lambda P: [(a,b) if P.le(a,b) else (b,a) for a,b in P.hasse_diagram().edges(labels=None)]
format_pt = lambda k: "'x{0}'".format(k+1)
format_relations = lambda relations: [[format_pt(a),format_pt(b)] for a,b in relations]
format_pts = lambda P: [format_pt(a) for a in P]
format_poset = lambda P: [format_pts(P), format_relations(cover_relations(P)), format_relations(le_relations(P))]
what_you_want = lambda n: [format_poset(P) for P in [posets.BooleanLattice(m)]]
print(what_you_want(m))
```

The following code does not work:

```
m=3
le_relations = lambda P: [(a,b) if P.le(a,b) else (b,a) for a,b in P.comparability_graph().edges(labels=None)]
cover_relations = lambda P: [(a,b) if P.le(a,b) else (b,a) for a,b in P.hasse_diagram().edges(labels=None)]
format_pt = lambda k: "'x{0}'".format(k+1)
format_relations = lambda relations: [[format_pt(a),format_pt(b)] for a,b in relations]
format_pts = lambda P: [format_pt(a) for a in P]
format_poset = lambda P: [format_pts(P), format_relations(cover_relations(P)), format_relations(le_relations(P))]
what_you_want = lambda n: [format_poset(P) for P in posets.YoungsLattice(m)]
print(what_you_want(m))
```

The only difference between two codes is that in the second code I have

```
what_you_want = lambda n: [format_poset(P) for P in posets.YoungsLattice(m)]
```

instead of

```
what_you_want = lambda n: [format_poset(P) for P in [posets.BooleanLattice(m)]].
```

Entering the second code gives an error. I do not really understand why the first works and the second does not, so any help is welcome how to fix the error.

Please give minimal code, that still catches the problem. It is also hard to see which is the "first code", and which is the "second one", when we have the full code blocks in one order, then only the problem line and its working cousin the the other order. The

`lambda n ...`

does not use an`n`

any longer. The minimal code to compare would be:Works. In the other code, there is

no listaround, andfails.

Is this the problem?This comes from the fact that`P`

and`Q`

have different classes and types (for the labels of the elements.) Let us compare: