How can I create a myJoin function?

Write your own function, called myjoin() which takes an arbitrary number of strings and appends them all together, similar to os.path.join() .

def myjoin(*args):
joined_string = ‘’
for arg in args:
# what goes here?
return joined_string

can anyone help with this section of exercise

If we follow the example, we get,

def myjoin(*args):
    return join(*args)

They just want you to fill in:

for arg in arg:
# what goes here?

If you look back to the beginning of the lesson to the example you see:

def shout_strings(*args):
  for argument in args:
    print(argument.upper())

Using that as as example, this was how I did it:

def myjoin(*args):
  my_string = ""
  for argument in args:
    my_string += argument
  return my_string

Thats just what I did… Solved thanks for the input

1 Like