0

len() function

message=input("Your text :") leng=len(message) print ("\nLenght:",leng) This program writing length symbols only befor space. Wats wrong ?

12th Aug 2016, 1:44 PM
Artkham Z
Artkham Z - avatar
1 Réponse
0
I am guessing that what you want to print out is "Length: (length of input)". If so, then the last line should say print ("Length: " + str(leng)). The print function does not take two arguments so what you need to do is concatenate strings. Since the len function returns an int, you will need to convert the variable leng from int to string using str.
12th Aug 2016, 3:02 PM
Jonathan Kwee
Jonathan Kwee - avatar