Hacker News new | past | comments | ask | show | jobs | submit login

It is working; the variable "number" is local to the generator expression and can't be used in the print statement. It works if you print something else instead (e.g. "Success!" in the article).

If you just want to print the numbers less than 10, it's easier to do:

  print [number for number in numbers if number < 10]
or

  print '\n'.join(str(number) for number in numbers if number < 10)
if you want the same formatting.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: