In the given code examples, there seems to be a misunderstanding.
The correct usage of the join() method in Python is as follows:
my_list = ["Hello", "world"]
print("-".join(my_list))
The join() method is called on the delimiter ("-" in this case), and the list you want to join is passed as an argument. It concatenates the elements of the list using the specified delimiter.
The incorrect code example you provided, print(my_list.join("-")), won't work because the join() method is a string method, not a list method. It should be used on a string to join a list of strings together, rather than being used directly on the list itself.
So, the correct and recommended approach is to use "-" as the delimiter and call join() on it, passing the list as an argument, as shown in the corrected code example.
To summarize, the reason for the correct usage being "-".join(my_list) is that the join() method is designed to be used on a string object and accepts an iterable (like a list) to join its elements together using the specified delimiter.