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", "!")

27th Aug 2021, 9:38 PM
Ruslan Bekaldiev
Ruslan Bekaldiev - avatar
2 Respuestas
27th Aug 2021, 10:07 PM
Slick
Slick - avatar
- 1
hi guys how are u
10th Sep 2022, 9:11 AM
Harkesh Mahlawat
Harkesh Mahlawat - avatar