4.2.13 Joining Lists into Strings: join()

Unit: Unit 4: Strings, Lists, and Tuples • Interactive Practice

Quick Answer & Summary:

Interactive Python programming tutorial and practice in your browser.

Interactive Challenge (Run Live in Browser):

# Assemble string outputs from lists using join()
tokens = ["www", "python", "org"]
tags = ["backend", "python", "ai", "fastapi"]

# 1. Join domain tokens with dots '.'
domain = ".".join(tokens)

# 2. Join tags with hashtag prefix and space separator
hashtag_string = " ".join(["#" + tag for tag in tags])

print("Domain:", domain)
print("Hashtags:", hashtag_string)
Open in Live Interactive Python Sandbox →