-2

I have a basic list EG : Test1 = [] then i used .append to add to it and fore EG it became: Test1 = ["hahaha", "lalalal", "mamama"]

at the end i print out the list but of course the brackets are there i checked other posts like this and didn't really understand could someone show me how it is done ?

matvey-tk
  • 641
  • 7
  • 18

3 Answers3

0

If you want them on the same line:

Via for loop.

for x in ["hahaha", "lalalal", "mamma"]:
    print(x, end=" ")

Or with str.join.

print(' '.join(["hahaha", "lalalal", "mamma"]))

Output

hahaha lalalal mamama 

Or on different lines:

for x in ["hahaha", "lalalal", "mamma"]:
    print(x)

Output

hahaha
lalalal
mamama
Jason
  • 2,278
  • 2
  • 17
  • 25
0

If you want to print the list as a string with a separating character (like a comma) you would use the join method of a string:

','.join(["hahaha", "lalalal", "mamma"])
cts
  • 1,790
  • 1
  • 13
  • 27
0

in 1 line:

Test1 = ["hahaha", "lalalal", "mamama"]
print(", ".join(Test1))

join fucntion can join multiple values using separator (and returns string):

"separator".join(values)
János Farkas
  • 453
  • 5
  • 14
  • While this code may answer the question, providing additional context regarding _why_ and/or _how_ it answers the question would significantly improve its long-term value. Please [edit] your answer to add some explanation. – Toby Speight Apr 11 '16 at 09:23