Update detect.py

Replaced generator with a list comprehension