0

I'm following along in this book, and although the below code runs, and produces the two hearts, I also end up with a 'None' at the end and I can't figure out why.

grid = [['.', '.', '.', '.', '.', '.'],
        ['.', 'O', 'O', '.', '.', '.'],
        ['O', 'O', 'O', 'O', '.', '.'],
        ['O', 'O', 'O', 'O', 'O', '.'],
        ['.', 'O', 'O', 'O', 'O', 'O'],
        ['O', 'O', 'O', 'O', 'O', '.'],
        ['O', 'O', 'O', 'O', '.', '.'],
        ['.', 'O', 'O', '.', '.', '.'],
        ['.', '.', '.', '.', '.', '.']]


def heart(list):
    for i in range(len(grid[0])):
        for j in range(len(grid)):
            print(grid[j][i],end=' ')
        print('')

    for i in range(len(grid[0])-1,-1,-1):
        for j in range(len(grid)):
            print(grid[j][i],end=' ')
        print('')

print(heart(grid))

I've added an image of the result here:

Successful hearts with ending None

0 Answers0