KnowledgeBoat Logo
|

Computer Science

Write a program that takes a sentence as an input parameter where each word in the sentence is separated by a space. The function should replace each blank with a hyphen and then return the modified sentence.

Python

Python String Manipulation

4 Likes

Answer

sentence = input("Enter a sentence: ")

modified_sentence = sentence.replace(' ', '-')

print(modified_sentence)

Output

Enter a sentence: Innovation drives progress
Innovation-drives-progress

Answered By

2 Likes


Related Questions