Skip to content

Instantly share code, notes, and snippets.

@tcpdump-examples
Last active February 7, 2022 10:28
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 tcpdump-examples/309d09fc3b8ef8ea1893e36668ff1bb5 to your computer and use it in GitHub Desktop.
Save tcpdump-examples/309d09fc3b8ef8ea1893e36668ff1bb5 to your computer and use it in GitHub Desktop.
Get list length in Python 3 Examples
len() function list = [10, 20, 30]
n = len(list)
print(“The length of list is: “, n)
for loop list = [‘Python’,’Java’,’Kotlin’,’Machine Learning’,’Keras’]
size = 0
print(“Length of the input string:”)
for x in list:
size+=1
print(size)
len() function for nested list nestedList = [‘Krishna’, 20,’John’, [20, 40, 50, 65, 22], ‘Yung’, 11.98]
print(“Original List = “, nestedList)
print(“Length of a Nested List = “, len(nestedList[3]))

how to get list length in python

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment