Python Forum
calculating length of string
Thread Rating:
  • 4 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
calculating length of string
#11
I think you don't need the length of string you want to calculate the digit in the length of string. 

you can use this code :-

your_string = 'qwertyuiop'
print len(str(len(your_string)))

Output:
2
Reply
#12
you want to know the number of terms ???

for example :- 

s = python is a script language

then it should return 5

for that you can use this code 

print len(s.split(' '))

where s.split(' ') will proivde you  list (['python', 'is', 'a', 'script', 'language'])

and len(s.split(' ')) will return the number of terms in s (5)

try it it may help you 

thanks for reading my reply
Reply
#13
Here is my solutions for your query :-

sentence = input('enter :-')
word_list = sentence.split(" ")
print (len(word_list))

User has been warned for this post. Reason: Necro
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How can i limit length string? perrfect 3 2,436 Feb-10-2020, 04:52 PM
Last Post: Jendker
  python gives wrong string length and wrong character thienson30 2 1,432 Oct-15-2019, 08:54 PM
Last Post: Gribouillis
  Highlight/Underline a string | ValueError: zero length field name in format searching1 1 1,778 Jul-01-2019, 03:06 AM
Last Post: metulburr
  Python find the minimum length of string to differentiate dictionary items zydjohn 3 2,135 Mar-03-2018, 05:23 PM
Last Post: Gribouillis
  Get string length RedSkeleton007 3 3,124 Dec-04-2017, 03:19 PM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020