0

This is my approach so far:

results = [for number in range(1,1001) max([divisor for divisor in range(1,10) if number % divisor == 0])]

Except I can't figure out why this doesn't work. All answers would be lovely, thanks!

Mike
  • 37
  • 6
  • Possible duplicate of [Understanding nested list comprehension](https://stackoverflow.com/questions/8049798/understanding-nested-list-comprehension) – John Jun 10 '18 at 20:44

1 Answers1

1

The order in which you use list comperhension is incorrect. Use

results = [max([divisor for divisor in range(1,10) if number % divisor == 0]) for number in range(1,1001) ]

The syntax is

[ expression for item in list if conditional ]

Source: http://www.pythonforbeginners.com/basics/list-comprehensions-in-python

yakobyd
  • 572
  • 4
  • 12