Skip to content

Instantly share code, notes, and snippets.

@IndhumathyChelliah
Created July 21, 2020 00:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IndhumathyChelliah/04a0325107e992a358031a54104a74c5 to your computer and use it in GitHub Desktop.
Save IndhumathyChelliah/04a0325107e992a358031a54104a74c5 to your computer and use it in GitHub Desktop.
#Using List Comprehension
l2=[i*i for i in range(1,11)]
print (l2) #Output: [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
# Using for loop
l1=[]
for i in range(1,11):
a=i*i
l1.append(a)
print (l1) #Output:[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment