1name = input("What is your name:- ")
2print("Hi "+name)
3
4lenth_got = len(name)
5print("so your name has got", lenth_got,"characters")
1mystring = 'Hello'
2#Counts the amount of letters in the string
3len(mystring) # = 5
4
5#Can also count the number of items in a list
6mylist = ['Hello', 'Goodbye', 'Morning']
7len(mylist) # = 3
1string = "hello"
2print(len(string))
3#>>> Outputs "5"
4if len(string) >= 10:
5 print("This string is grater then 10")
6
7if len(string) <= 10:
8 print("This string is smaller then 10")
9
10# Outputs "This string is smaller then 10"
1# Python program to demonstrate the use of
2# len() method
3
4# Length of below string is 5
5string = "geeks"
6print(len(string))
7
8# Length of below string is 15
9string = "geeks for geeks"
10print(len(string))
1# to get the length of a string or array, use the len() method
2my_string = "Hello World"
3my_list = ["apple", "banana", "orange"]
4
5print(len(my_string)) # outputs 11
6print(len(my_list)) # outputs 3