3. Make a list - but why?


#1



https://www.codecademy.com/courses/python-beginner-en-4XuFm/0/5?curriculum_id=4f89dab3d788890003000096


I don't understand why I have to put square brackets around the "o". Could someone explain please? Thank you...


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


#2

Making it a list allows us to access it using index when guessing the ships. You will understand why it's important later in the lesson. Message me if it still doesn't make sense.


#3

Yeah that makes sense to me now, thank you. I have yet to complete the exercise (which I will - eventually), but I get why since the game is a battleship type game, we are gonna need some way so being about to refer to the "o" rows on the board.


#4

Yes, it also serves as a visual for the players. :slight_smile:


#5

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