Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

How can you replace string space with a given character in Python?

Given a positive integer num, write a function that returns True if num is a perfect square else False.

user-image
Question added by Mohamed Raashid
Date Posted: 2023/11/08

Python

string = "Once in a blue moon";

ch = '-';

#Replace space with specific character ch.

string = string.replace(' ', ch);

print("String after replacing spaces with given character: ");

print(string);

More Questions Like This