How do i transform a list into a string whitout making the string containing the signs

so i tried to make a list not contain the signs , and ().
but somehow it does, to anyone who kno da wae, please teach me.

List = ("i ", "eat ", "an ", "apple ")
List2 = ("sitting ", "on ", "a ", “chair”)

Test_text = (str(List) + str(List2))

print(Test_text)
print(len(Test_text))

What you create here are tuples, not lists.

If you create a list, do as follows:

>>> l = ['Hup, ', 'Holland']
>>> l1 = [ 'Leeuw, ', 'Hempie']
>>> l
['Hup, ', 'Holland']
>>> l1
['Leeuw, ', 'Hempie']
>>> l.extend(l1)
>>> l
['Hup, ', 'Holland', 'Leeuw, ', 'Hempie']
>>> ''.join(l)
'Hup, HollandLeeuw, Hempie'

For tuples it is more elaborate.

1 Like

thank you i now understand that it was a tuple and not a list, by the way, whats the difference betwem a list and a tuple?

A list is mutable which means you can change it in place after it is
created, but tuples are immutable which means they can’t be changed in
place, you have to create a new one:

alist = [1, 2, 3]
alist.append(4)
print(alist)
# ==> [1, 2, 3, 4]

atuple = (1, 2, 3)
atuple.append(4)
# ==> raises AttributeError
'tuple' object has no attribute 'append'

atuple = (1, 2, 3)
atuple = atuple + (4,)  # creates a new tuple
print(atuple)
# ==> (1, 2, 3, 4)

The intention is for lists to be used for homogenous data with
unpredictable length:

scores = []
for student in school():
    score = get_exam_results(student)
    scores.append(score)

# number of scores is unknown ahead of time, but each
# score is the same kind of value, say, 0-100 out of 100.

but tuples are used for heterogeneous data of fixed size (usually quite
small):

position = (latitude, longitude)
person = (personal_name, family_name, address, phone_number)
shopping_cart_item = (item, colour, quantity)

It doesn’t matter whether you have a list or a tuple, so long as each
item is a string, you can join all the substrings with the string “join”
method:

items = ("Hello", "World!")
"  --  ".join(items)
# ==> returns "Hello  --  World!"

items = ["a", "bbb", "cccc", "dd"]
"-".join(items)
# ==> returns "a-bbb-cccc-dd"

If the items are not strings, you need to turn them into strings first.
Here are three ways that you can do this:

items = [1, 2, 3, 4]
for position, num in enumerate(items):
    items[position] = str(num)

items = [1, 2, 3, 4]
items = list(map(str, items))

items = [1, 2, 3, 4]
items = [str(num) for num in items]
1 Like

Thank you peoples for teaching me