# Creating a List
List1 =[]print(len(List1))# Creating a List of mixed values
List2 =["Softhunt",".net",14]print(len(List2))# Creating a List of numbers
List3 =[10,20,14,31,3]print(len(List3))
#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
list_1 =["Hello",1,"World",2]# if you want length of this lins use len() functionprint(len(list_1))# if you want size in bytesimport sys
print(sys.getsizeof(list_1),"Bytes")
# plz suscribe to my youtube channel --># https://www.youtube.com/channel/UC-sfqidn2fKZslHWnm5qe-A#get length of list
list_example =["python","ruby","java","javascript","c#","css","html"]print(len(list_example))
#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)