Ask Your Question

Revision history [back]

Given your value for LL, namely LL = [[x_0, '>=', 0], [x_1, '>=', 0]], you can do this

sage: [[str(a) for a in b] for b in LL]
[['x_0', '>=', '0'], ['x_1', '>=', '0']]

to convert each entry to a string. You can concatenate those strings using the join method for strings:

sage: [''.join([str(a) for a in b]) for b in LL]
['x_0>=0', 'x_1>=0']

To get exactly what you asked for, put the results of that join operation in a list:

sage: [[''.join([str(a) for a in b])] for b in LL]
[['x_0>=0'], ['x_1>=0']]

Given your value for LL, namely LL = [[x_0, '>=', 0], [x_1, '>=', 0]], you can do this

sage: [[str(a) for a in b] for b in LL]
[['x_0', '>=', '0'], ['x_1', '>=', '0']]

to convert each entry to a string. You can concatenate those strings using the join method for strings:

sage: [''.join([str(a) [' '.join([str(a) for a in b]) for b in LL]
['x_0>=0', 'x_1>=0']
['x_0 >= 0', 'x_1 >= 0']

To get exactly what you asked for, put the results of that join operation in a list:

sage: [[''.join([str(a) [[' '.join([str(a) for a in b])] for b in LL]
[['x_0>=0'], ['x_1>=0']]
[['x_0 >= 0'], ['x_1 >= 0']]