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
61
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,769
Messages
2,569,577
Members
45,052
Latest member
LucyCarper

Latest Threads

Top