Amadeus
0
Q:

len python

mystring = 'Hello'
#Counts the amount of letters in the string
len(mystring)	# = 5	

#Can also count the number of items in a list
mylist = ['Hello', 'Goodbye', 'Morning']
len(mylist)		# = 3
6
# to get the length of a string or array, use the len() method
my_string = "Hello World"
my_list = ["apple", "banana", "orange"]

print(len(my_string)) # outputs 11
print(len(my_list)) # outputs 3
2

New to Communities?

Join the community