Skip to content

Instantly share code, notes, and snippets.

@MaodeColombia
Last active November 23, 2021 02:19
Show Gist options
  • Save MaodeColombia/2278df0d242a0a39358ebc82faf38560 to your computer and use it in GitHub Desktop.
Save MaodeColombia/2278df0d242a0a39358ebc82faf38560 to your computer and use it in GitHub Desktop.
Converting a function into a list comprehension
def times_tables():
lst = []
for i in range(10):
for j in range (10):
lst.append(i*j)
return lst
lst = [ i*j for i in range(10) for j in range (10)]
times_tables() ==lst
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment