0
Python core 103 'Adding words'
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 So my question is: how can I make this code more clear without adding list? My example: def concatenate(*args): my_list = [] for i in args: my_list.append(i) new_str = '-'.join(my_list) print(new_str) concatenate("I", "love", "Python", "!")
2 odpowiedzi
+ 8
By using list comprehension
https://code.sololearn.com/cO9r5O0xl1N4/?ref=app
- 1
hi guys how are u