Fix a complicated list-cast-map-list antipattern
Fix a complicated list-cast-map-list antipattern

The previous version contained multiple antipatterns:

- casting to list
- map when comprehension can be used
- map over a comprehension
- len(range(list)) looping
qutip/qutip,anubhavvardhan/qutip,anubhavvardhan/qutip,cgranade/qutip,cgranade/qutip,qutip/qutip