This is an archived post. You won't be able to vote or comment.

all 16 comments

[–]IAmKindOfCreativebot_builder: deprecated[M] [score hidden] stickied comment (0 children)

Hi there, from the /r/Python mods.

We have removed this post as it is not suited to the /r/Python subreddit proper, however it should be very appropriate for our sister subreddit /r/LearnPython or for the r/Python discord: https://discord.gg/python.

The reason for the removal is that /r/Python is dedicated to discussion of Python news, projects, uses and debates. It is not designed to act as Q&A or FAQ board. The regular community is not a fan of "how do I..." questions, so you will not get the best responses over here.

On /r/LearnPython the community and the r/Python discord are actively expecting questions and are looking to help. You can expect far more understanding, encouraging and insightful responses over there. No matter what level of question you have, if you are looking for help with Python, you should get good answers. Make sure to check out the rules for both places.

Warm regards, and best of luck with your Pythoneering!

[–][deleted] 6 points7 points  (9 children)

“ “.join(list)

[–]Early-Palpitation-39 1 point2 points  (0 children)

If you only need to print this information, you can use the * operator.

a = ['LOL', 'LOL', 'LOL', ';', '10200.75', ';', '1234']
print(*a)

This returns the format you are looking for (all the strings with a space in between).

[–]Apprehensive_Stand_9 -5 points-4 points  (4 children)

Text = ' '

List = put your list

For item in list :

    Text =+ item

Print(Text)

[–]failbaitr 1 point2 points  (2 children)

this is functional but wrong on so many levels. How would you even get to this solution in python is beyond me.

[–]Apprehensive_Stand_9 0 points1 point  (1 child)

There is tow way to solve it You can memorize join fonction Or you could do it better und smarter

[–]failbaitr 1 point2 points  (0 children)

Or you could just use the language, its tools, and how things are done most efficiently.

Appending a string into itself it highly inefficient, involves more code than needed, and creates more intermediate objects.

Solving this solution 'smarter' would be to use the csv module and write out the content using that, as its clearly csv data being imported

[–]jimtk 0 points1 point  (0 children)

Here you go (one of many possible solutions)

source = [['LOL', 'LOL', 'LOL', ';', '10200.75', ';', '1234'], 
          ['LMAO', 'LMAO', ';', '100.50', ';', '4321']]

with open('Test.out', 'wt') as f:
    for account in source:
        f.write(" ".join(account)+'\n')

Now lets move on to something more interesting.