list comprehension


/ Published in: Python
Save to your folder(s)



Copy this code and paste it in your HTML
  1. def main():
  2. print [func(x) for x in range(10)]
  3. print map(func,range(0,10))
  4.  
  5. def func(x):
  6. return x**2
  7.  
  8. if __name__ == '__main__':
  9. main()

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.