Perhaps use sympy.core.compatibility.iterable instead of checking the type? Or is there a specific reason to allow lists but e.g. not tuples?