Return a board read from open file board_file. The board file will contain one row of the board per line
for a .txt looking like the below (already opened): EFJAJCOWSS SDGKSRFDFF ASRJDUSKLK HEANDNDJWA ANSDNCNEOP PMSNFHHEJE JEPQLYNXDL Return a board that will contain each row on a different line. Newlines are not included in the board. I have the below code: def read_board(board_file): file = open(board_file, 'r') line = file.readline() newList = '' while line != '': newList = newList + line.strip('\n') + '\n' line = file.readline() return newList The result is : 'EFJAJCOWSS\nSDGKSRFDFF\nASRJDUSKLK\nHEANDNDJWA\nANSDNCNEOP\nPMSNFHHEJE\nJEPQLYNXDL\n' Any tips on how I can get this to list each row on a different line, as mentioned above? +'\n' doesn't do the trick...
file.readlines() gives list of lines lst_lines = file.readlines() lst_lines will be like: ['EFJAJCOWSS\n','SDGKSRFDFF\n'........] Now you can iterate over lst_lines list with for loop line,line is different line for line in lst_lines: print(line)
prettifying a part of the html doc using beautifulsoup
Django concatenate two querysets for same model
How can I validate input to accept only binary numbers?
Custom route predicates in Pyramid
Why is my query for a structured property failing with BadFilterError?
Simple Audio Units Host to drive an Audio Units Instrument
kivy language cumbersomeness and rationale behind it
detect if variable is of sympy type
Add markers on line plot from another vector
Does asyncio.wait return only after all done_callbacks were called?
How to parse a htmlpage with lxml with <br /> screwing up?
Python Moviepy module: output video?
Many Problems with python's virtualenv
How to add a title to Seaborn Facet Plot
What is happening in Python 3 when I call list() on an iterator?
In kivy using screenmanager how can I add other widgets like scatter?