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...