-2
def concatenate(*args):
    args = [args]
    for i in args:
        return i[0] + '-' + i[1] + '-' + i[2] + '-' + i[3]

print(concatenate("I", "love", "Python", "!"))

The result should be 'I-love-python-!' , but should be similar for any number of arguments. Newbie here

LukasNeugebauer
  • 1,215
  • 6
  • 9
  • 4
    `def concatenate(*args); return "-".join(args)` – matszwecja May 25 '22 at 12:00
  • Does this answer your question? [Can a variable number of arguments be passed to a function?](https://stackoverflow.com/questions/919680/can-a-variable-number-of-arguments-be-passed-to-a-function). Also, check this out : [How do I concatenate items in a list to a single string?](https://stackoverflow.com/questions/12453580/how-do-i-concatenate-items-in-a-list-to-a-single-string) – Mateo Vial May 25 '22 at 12:01
  • See how the [`for` loops work](https://www.w3schools.com/python/python_for_loops.asp) – Brinfer May 25 '22 at 12:01

0 Answers0