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!
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!
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