string=input('enter string:') char=input('enter character to replace space:') modify_String=string.replace(' ',char) print('After Replacing space with',char,'string will be',modify_String) (OR) string=input('enter string:') char=input('enter character to replace space:') concate='' for i in string: if i==' ': i=char concate+=i print('After Replacing space with',char,'string will be',concate) (OR) string=input('enter string:') char=input('enter character to replace space:') print('After Replacing space with',char,'string will be',char.join(string.split()))