Last active
June 8, 2022 08:28
-
-
Save tushar4303/7735d7bc559c5063e085bcffc02b50a7 to your computer and use it in GitHub Desktop.
Imp points to be noted in python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
---------------------------------------------------------------------------------- | |
Python Notes | |
---------------------------------------------------------------------------------- | |
#when you equate a list to a new list, it doesn't actually copy the list | |
but instead points to the locations in your original list thus any changes | |
made in the new list reflects in the old one as well | |
my_list = your_list | |
#to avoid this do: | |
my_list = your_list[:] or my_list = your_list.copy() | |
------------------------------------------------------------------------------------ | |
#dictionary key can be a tuple, string, number but not a list, because lists are | |
mutable and dictionary doesn't like the key to change | |
------------------------------------------------------------------------------------ | |
python doesn't support i++ or i--- | |
but does support i += 1, etc | |
------------------------------------------------------------------------------------ | |
END | |
---------------------------------------------------------------------------------- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment