Make a list


Getting error: Oops, try again. Your code looks a bit off. Check the Hint if you need help! Your code threw the following error: 'return' outside function (python, line 5)

board = []
for O in range(0,5):
    print ["O"] * 5
return board
print board


Instruction says this..

Inside the loop, .append() a list containing 5 "O"s to board, just like in the example above

two lines of code..

print ["O"] * 5

Instruction have not asked to print ["O"] * 5
It asked to append ["O"] * 5 to board ?


Not to mention I didn't need a return statement...


Exactly,as you'd have seen this message (Error : return statement outside of function)

(reading theory+ following instruction solves more than half of the problem..last part remains is to find a logic to accomplish the final part of problem.)


you can try this Code is Work:
board = []
for i in range(0,5):
lists = ["O"] * 5
print board


Hi! try this code:


for i in range(0,5):
print board

  1. You dont need to return the statement as the error have shown :slight_smile:
  2. ["O"] * 5 put it together as an board.append, as you need to "append" the board list with the Os since its a empty list.

Hope it helps! :slight_smile:


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