Ask Your Question

Revision history [back]

If v is in R then you can use e.g. the condition v[:3] == '$a_' to check that the first three characters in v are $a_.

sage: [v for v in R if v[:3] == '$a_']
['$a_{3}$', '$a_{5}$']

If v is in R then you can use e.g. the condition v[:3] == '$a_' to check that the first three characters in v are $a_.

sage: [v for v in R if v[:3] == '$a_']
['$a_{3}$', '$a_{5}$']
sage: for v in R:
....:     if v[:3] == '$a_':
....:         print(v)
....:                                                                                                                                                                                         
$a_{3}$
$a_{5}$