Write a Python program according to the task. Predictprocessing of the specified exceptional situation.

Joined
May 28, 2022
Messages
7
Reaction score
1
Task: Given text. Find, count and remove all spaces
Exceptional:The original text does not contain spaces
 
Joined
May 11, 2022
Messages
60
Reaction score
6
Python:
x = input("desired text to be analyzed ")
numspace = 0
i = 0

while i < len(x):
   if x[i] == " ":
      x = x[:i] +x[i+1:]
      numspace += 1
   else:
      i+=1
print(numspace,x)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,738
Latest member
JinaMacvit

Latest Threads

Top