Los métodos de lista se discuten en este artículo.
1. len() : – Esta función devuelve la longitud de la lista.
Python3
# Python code to demonstrate the working of # len(), min() and max() # initializing list 1 lis = [2, 1, 3, 5, 4] # using len() to print length of list print ("The length of list is : ", end="") print (len(lis)) # using min() to print minimum element of list print ("The minimum element of list is : ", end="") print (min(lis)) # using max() to print maximum element of list print ("The maximum element of list is : ", end="") print (max(lis))
Python3
# Python code to demonstrate the working of # index() and count() # initializing list 1 lis = [2, 1, 3, 5, 4, 3] # using index() to print first occurrence of 3 # prints 5 print ("The first occurrence of 3 after 3rd position is : ", end="") print (lis.index(3, 3, 6)) # using count() to count number of occurrence of 3 print ("The number of occurrences of 3 is : ", end="") print (lis.count(3))
Publicación traducida automáticamente
Artículo escrito por GeeksforGeeks-1 y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA