

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 6
click for more info
Not enough gems
Cost: 6 gems
1: Number Sum
incomplete
2: Find Min
incomplete
3: Remove Non-Integers
incomplete
4: Factorial
incomplete
5: Area Sum
incomplete
6: List Division
incomplete
7: Join Strings
incomplete
8: Unit Tests
incomplete
9: Fix a Failing Test
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
The + operator in Python can be used to concatenate (smoosh) strings together. For example:
print("hello" + " " + "world")
# hello world
author: str = "Tolkien"
message: str = "The " + "world never deserved " + author
print(message)
# The world never deserved Tolkien
Complete the join_strings() function. It takes a list of strings and returns a new single string.
The new string is the concatenation of all the input strings from the list end-to-end, in order, with a comma between them. If the list is empty, return an empty string. For example:
string_list: list[str] = ["Annie", "Reiner", "Bertholdt"]
joined_string: str = join_strings(string_list)
print(joined_string)
# "Annie,Reiner,Bertholdt"
string_list = ["Eren", "Mikasa", "Armin"]
joined_string = join_strings(string_list)
print(joined_string)
# "Eren,Mikasa,Armin"
Do not use the built-in .join() method... we're trying to learn how this works manually.
string[:-2]) just like you can with lists.