What does len() mean in python, and what is the difference between raw_input and input?

Asked 08-Mar-2018
Viewed 623 times

0

What does len() mean in python, and what is the difference between raw_input and input?

1 Answer


0

len(): Python string length function which counts the length of the string.
len() function is an inbuilt function in Python that returns the length of the string. 
Syntax: 
len(string) 
example: 
list1, list2 = [12, 'mindstick', 'software'], [54, 'prakash'] 
print "First list length : ", len(list1)
print "Second list length : ", len(list2)
// Length of below string is 9. 
string = "mindstick"
print(len(string))
Difference between raw_input() and input() functions in Python: 
The function raw_input() presents a prompt to the user arg of raw_input([arg])) gets input from the   
user and returns the data input by the user in a string.
name = raw_input("What is your name? ") 
print "mindstick, %s" %name
This differs from input() in that the latter tries to interpret the input given by the user; it is   usually best to avoid input() and to stick with raw_input() and conversion code. 
name = input("What is your name? ")
print("mindstick, %s." %name)
name = eval(raw_input("what is your name?")) 
what is your name?mindstick