Search code examples
pythonpython-3.xbeautifulsouplinespace

Printing without blank lines


I just write print(bl). (bl is something that I scraped). And is returning these.

                                                    ANT1440809






                                                    ANT1441876






                                                    ANT1442526






                                                    COSU6304518110






                                                    COSU6305225900






                                                    COSU6305225920

COSU6308165500

COSU6308432610

                                                    COSU6308437200

COSU6308546590

                                                    DXB0581358






                                                    EGLV480100024576






                                                    EGLV480100027435






                                                    EGLV751100045218






                                                    EGLV751100045749






                                                    EGLV751100046320






                                                    EGLV751100048004






                                                    EGLV751100048438






                                                    EGLV751100048446






                                                    EGLV751100048454

EGLV751100049540

                                                    EGLV751100050963






                                                    EGLV751100051021

EGLV751100051501

As you can see it begins with blank lines then the code I extract and then again there are blank lines between the codes, and they don't print in a column. How can I make it print like this?

Code1

Code2

Code3


Solution

  • Try print(bl.strip()). It will remove the whitespace surrounding the string