Created
April 10, 2020 11:23
-
-
Save rishisidhu/ca3a7b714334548e8252eca0713134a9 to your computer and use it in GitHub Desktop.
List Operations 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
#Lists | |
l2 = [4,1,3,9,7] | |
l3 = ['a','ab', 'abc','ab', 'ab'] | |
#List Methods | |
l2.sort() # Sort | |
l2.append(12) # Add an element at the end | |
sum(l2) # Sum all the elements | |
max(l2) # Find the maximum element | |
min(l2) # Find the minimum element | |
l2.extend(l3) # Add elements of another list to this list | |
l2.insert(1,13) # Insert element at a specific index | |
l2.remove('a') # Remove a specific element | |
l2.count('ab') # Count occurrences of element | |
l2.reverse() # Reverse List | |
l2.pop(4) # Remove element from this position |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment