Ask Your Question

Revision history [back]

To complement @tmonteil's answer.

In some cases a lambda function is also okay.

It takes up less lines than a def function.

sage: cond = lambda x, y: "Accepté" if bool(x<y) else "Rejeté"

Then:

sage: a, b, c, d, e, f = [1 .. 6]
sage: essay = [[cond(a, b)], [cond(c, d)], [cond(e, f)]]
sage: hc = ['test', r'A', r'B', r'C']
sage: table(essay, header_row=['résultat'], header_column=hc)
  test | résultat
+------+----------+
  A    | Accepté
  B    | Accepté
  C    | Accepté