-
The
join()
method used with strings, -
In contrast, the
os.path.join()
method is used for constructing file paths by joining different path components. a_PATH_JOIN
-
The join() method used with strings (e.g., ", ".join(iterable)) is designed to concatenate a sequence of strings into a single string, inserting a specified delimiter between each element.
-
- For example
, ", ".join(["apple", "banana", "cherry"])
- For example
-
- results in "apple, banana, cherry".
In contrast, the os.path.join() method is used for constructing file paths by joining different path components. It ensures that the appropriate file system separators are used for the operating system. For example, os.path.join("folder", "subfolder", "file.txt") produces a correctly formatted path such as "folder/subfolder/file.txt" on Unix-based systems or "folder\subfolder\file.txt" on Windows. This method simplifies path handling and enhances cross-platform compatibility.
-
.join
will turn the list into a string, separated by whatever the string is. -
you can add white spaces, symbols, letters , example:
-
' '.join
or', '.join
or'/ '.join
etc...
print("You have used these letters: ", ' '.join(used_letters))
# 🔴 output
"a", "b",
#
#https://github.com/nadiamariduena/python-intro-2024-privat/blob/master/LESSON_19_PPROJECTS/random_Hangman/README.md