Answer to Question #225360 in Python for raj

Question #225360

You are given a word W as input. Print W by adding a hyphen (-) between each letter in the word.


Explanation

In the given example, the word is

Hello.So, the output should be H-e-l-l-o.


1
Expert's answer
2021-08-11T14:17:05-0400
# 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()

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS