#a list
cars =['Ford','Volvo','BMW','Tesla']#some updates on list
cars.append('Honda')
cars.append('Tata')#find length of list
length =len(cars)print('Length of the list is :', length)6
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]))
#get length of list in Python using for loop
List =[‘Python’,’Java’,’Kotlin’,’Machine Learning’,’Keras’]
size =0print(“Length of the input string:”)for x in List:
size+=1print(size)
Output:
Length of the input string:5
# It doesn't matter what is the type of the item# It will count the number of items in the list
x =[1,2,5.67,2.45,'John','Pat',True,False]
length =len(x)# This gives us an integerprint('number of items in the list is:', length)