Python Practice › List Programs › Program 31
Join elements with a special character
Write a Python program to merge all elements of a list into one string using a special character.
Input
["sqa", "tools", 2026, "python"], separator "#"
Output
sqa#tools#2026#python
Approach
- Convert each item to str and join with the separator.
Solution
items = ["sqa", "tools", 2026, "python"]print("#".join(str(x) for x in items))Output
sqa#tools#2026#python
Line by line
Line 2
join only accepts strings, so the number is converted first.
Learn the concept
New to this topic? Read the lesson, then come back.