Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
removing spaces
#1
hello I have to calculate the arithmetic mean in the text (the number of letters divided by the number of sentences). The problem is that when counting letters, it also counts spaces and the result is spooky. How can I easily exclude joints from counting?
Text = input("give text: ")
characters = len(Text)
words = len(Text.split())
a = characters
b = words
division = a/b
print("words in this text hawe ", division, "characters")
Reply


Messages In This Thread
removing spaces - by msaiahnl - Jul-25-2022, 02:56 PM
RE: removing spaces - by rob101 - Jul-25-2022, 03:31 PM
RE: removing spaces - by deanhystad - Jul-25-2022, 03:34 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Removing leading\trailing spaces azizrasul 8 2,801 Oct-23-2022, 11:06 PM
Last Post: azizrasul
  removing spaces/tabs after used .strip() zarize 0 1,618 Sep-11-2019, 12:46 PM
Last Post: zarize

Forum Jump:

User Panel Messages

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