FAQ: Learn Python: Function Arguments - Positional Argument Unpacking


This community-built FAQ covers the “Positional Argument Unpacking” exercise from the lesson “Learn Python: Function Arguments”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Learn Python 3

FAQs on the exercise Positional Argument Unpacking

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

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:

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

This works on my raspberry pi using Python 3.6.8. The output for exercise 2 matches the output for exercise 1. The Codecademy feedback line, however, returns “Does myjoin() concatenate two strings?” [It worked in the Codecademy interface without an error message sometime later.]

def myjoin(*path_segments):
  full_path = ""
  for path_segment in path_segments:
    join(full_path, path_segment)
  return full_path

answer2 = myjoin(path_segment_1, path_segment_2, path_segment_3)
def my_join(*paths):
  joined = ''
  for path in paths:
    sep = ''
    if path[0] != '/':
      sep = '/'
    if path[-1] == '/':
      clean_path = path[:-1]
    	clean_path = path
    joined += sep+str(clean_path)
  return joined

a = 'a/c/sa/'
b = '/b'
c = 'c/'
abc = my_join(a,b,c)

why doesn’t it complete the task? The output is correct.

I don’t understand this hint.

def myjoin(*args):
  new_path = args[0]
  for argument in args[1:]:
    new_path += argument
  return new_path
print(myjoin(path_segment_1, path_segment_2, path_segment_3))  




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



in that regard this hint is just confusing. “Does myjoin() concatenate two strings?” led me to the += solution which is clearly not correct… Why is the hint leading you to a wrong solution?

because its a hint, not a solution.

this is not the code from the code from the hint:

def myjoin(*args):
  new_path = args[0]
  for argument in args[1:]:
    new_path += argument
  return new_path
print(myjoin(path_segment_1, path_segment_2, path_segment_3))  

this is the hint:

def myjoin(*args):
  joined_string = args[0]
  for arg in args[1:]:
    # what goes here?
  return joined_string

we still have to do what goes here? comment, including file separators. matthatters forgot to include the file separators (/). He is on the right path, and close, butt not entirely there yet.