Make A List


#1



Battleship!: Make a List


The error message says I don't have 5 rows, but I'm not sure how to do this?


def battleship(x):
    board = []
    for lst in x:
        range (0,5)
        board.append(["O"] * 5)
    return battleship


#2

For starters, you shouldn't be using a function for this part of the exercise. Secondly, might I suggest replacing that x in your for loop with that range(0,5) you have under it?

TL;DR... You are overthinking this. Try following this template:

VARIABLE = []

for EACH in range(0, 5):
    VARIABLE.append(["O"] * 5)

print VARIABLE

#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.