- This topic is empty.
Viewing 1 post (of 1 total)
Viewing 1 post (of 1 total)
- You must be logged in to reply to this topic.
join(line) directly in Python?❌ Answer: No.
join() is not a standalone function like len() or print().
✅ It is a string method, so it must be called like this:
"separator".join(list_items)
";".join(line) instead of join(line)?✅ Answer:
Because Python needs to know what separator to place between each element of the list.
Example:
";".join(["Amit", "98765", "12345"])
Output:
Amit;98765;12345
;, how can I join without it?✅ Answer:
Use an empty string "" as the separator:
"".join(line)
Example:
line = ["Amit", "98765", "12345"]
print("".join(line))
Output:
Amit9876512345
"" as the separator?✅ Answer:
All items get joined without any gap, which can make the output harder to read.
Example:
"".join(["Rajeev", "99999"])
Output:
Rajeev99999
;?✅ Answer: Yes ✅ You can use any separator you want, like:
" ".join(line)
",".join(line)
" - ".join(line)
✅ Final Summary:
You must write "something".join(line) — and if you want no separator, use:
"".join(line)
