37
38def tot_sides(y, dice):
39 """Sum of dice equal to a value 'y'"""
40 return sum([x for x in dice if x == y]) 41
42
43def count_sides(v, dice):
Using a container in place of a generator for a calls that can accept both, slows down the performance. Consider using generators for all function calls which accept both containers and genertors.
# List comprehension is unnecessary here
set([student.name for student in student])
sum([y**2 for y in list(range(10))])
set(student.name for student in students)
sum(y**2 for y in list(range(10)))