Adding word | SoloLearn: Learn to code for FREE!


Adding word

You need to write a function that takes multiple words as its argument and returns a concatenated version of those words separated by dashes (-). The function should be able to take a varying number of words as the argument. Sample Input this is great Sample Output this-is-great How to solve I was try more than 15 times :(

10/21/2020 5:06:25 PM


8 Answers

New Answer


Pritee please don't post πŸ™… a challenge in new thread perhaps, there is many thread to do it tho


l = ['this', 'is', 'great'] print('-'.join(l))


If you are having difficulty then check out this.. I have tried to explain everything in here.. Do the changes you want.


Where is your attempt show us Use .join method to join them after appending them to a list


def add(*words): return '-'.join(words) print(add('w0', 'w1', 'w2'))


def concfunc(*conc_words): return '-'.join(conc_words) print (conc_words) print(concfunc("I", "love", "Python","!"))


Thanks 😊


print ("Enter words for concatenating separated by space") input_words = input() word_list = input_words.split() joined_words = "-".join(word_list) print (joined_words)