Simple (hopefully) Python issue. How to return a list in multiple lines -


I am looking to return a list in several rows, and it is able to determine how many rows Returned

ex) // just psuedocode

, 'virginia', 'air'] foo (l) // I'm looking for such a return ['Alabama', 'Rangado', 'Virginia', 'Heavy]]

// tldr; How do you return a list with only one element per list?

There is a difference in the list and printing screen, while return value is an internal object, in which formatting Can not add formatting when converting an object to print the object. Here others have shown how to join the string with line breaks but there is a second option to print data in good formats to read on screen:

  gt; & Gt; Pprint import from pprint & gt; & Gt; & Gt; Pprint (['-' * 20] * 5) ['--------------------', '------------- ------- ',' -------------------- ',' ----------------- --- ',' -------------------- ']  

Once it's hard to read, Pprint automatically separates them into separate lines Pipint will also work on other data types, such as dictionary.


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -