It is simple and straight forward and it can be achieved using 2 methods : replace and split with join

Method 1 : replace
strname='python is simple'
print(strname.replace(' ','-'))

Method 2 : split with join
strname='python is simple'
print('-'.join(strname.split()))