Adding word | SoloLearn: Learn to code for FREE!

0

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

Pritee

8 Answers

New Answer

+6

Pritee please don't post πŸ™… a challenge in new thread perhaps, there is many thread to do it tho https://www.sololearn.com/discuss/475577/?ref=app https://www.sololearn.com/discuss/497411/?ref=app https://www.sololearn.com/discuss/1701380/?ref=app https://www.sololearn.com/discuss/1482337/?ref=app

+5

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

+5

If you are having difficulty then check out this.. I have tried to explain everything in here.. Do the changes you want. https://code.sololearn.com/ckKvB8v8Gf0K/?ref=app

+3

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

+3

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

+1

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

0

Thanks 😊

0

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