Make a list _ lesson 3


#1



Make a list in the Battleship Game

I get the following error,
"Traceback (most recent call last):
File "python", line 3, in
NameError: name 'x' is not defined


board = []

for i in range(x):
    if x[i] < 6:
        x[i] = x[i] + 'O'
    print x
    

What is wrong with this code?


#2

I think u should be using the pre defined function on the exercise


#3

Your loop is going over the variable x which has yet to be defined.

That is your issue, change the x to board and you should have no issue.

Also just do this

for i in board:  # Now you can check the object directly
    if i is str():
        print("There is a string here!", i)
    else:
        print("Failed!", i)