You are given a word W as input. Print W by adding a hyphen (-) between each letter in the word.
In the given example, the word is
Hello.So, the output should be H-e-l-l-o.
# Python 3.9.5
def enter_word():
word = input('Enter word: ')
return word
def word_by_hyphen(word):
word_with_hyphen = ''
for i in word:
word_with_hyphen += i + '-'
return word_with_hyphen[0:-1]
def main():
word = enter_word()
print(word_by_hyphen(word))
if __name__ == '__main__':
main()
Comments
Leave a comment