List: phrase.replace(‘ ‘,’-‘)

A little help with the spaces in the phrase:


phrase = "have a good day"
phrase = phrase.replace(' ','-') # replace space with dash
newphrase = ''

blanks = '_ ' * len(phrase) # underscore plus space

for i in range(len(phrase)):
    newphrase += phrase[i] +' ' # add a space to each letter to match
                                # the underscores plus space


for i in range(len(blanks)):
    if newphrase[i] == '-':
        blanks = blanks[:i] + '-' + blanks[i+1:] # replace the underscore
                                              # with the corresponding dash

print(newphrase)
print(blanks)


##>>> 
##h a v e - a - g o o d - d a y 
##_ _ _ _ - _ - _ _ _ _ - _ _ _ 
##>>>