Skip to content

Instantly share code, notes, and snippets.

@IndhumathyChelliah
Created August 30, 2021 22:48
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/f2e631323bdd6ef48efe5ae49b35e303 to your computer and use it in GitHub Desktop.
Save IndhumathyChelliah/f2e631323bdd6ef48efe5ae49b35e303 to your computer and use it in GitHub Desktop.
original_list=[1,2,3]
#Copying list using list comprehension
copied_list=[ i for i in original_list]
print(copied_list)
#Output:[1, 2, 3]
print(original_list)
#Output:[1, 2, 3]
#checking the id of both original and copied list
print(id(original_list))
#Output:27800264
print(id(copied_list))
#Output:27799880
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment