7. Hide


#1

Can anyone help me? i keep getting the message: Oops, try again. Did you create a function called random_row?
My code is as follows:

from random import randint

board = []

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

def print_board(board):
for row in board:
print " ".join(row)

Add your code below!

from random import randint

def random_row(board):
return radint(0, len(board) - 1)

def random_col(board):
return radint(0, len(board) - 1)

random_row(board)
random_col(board)


#2

Can you add triple backticks around your code, so it's formatted with the tabs and everything?

```
^Those are backticks.
Add them before your code.
Then add three more after your code.

#4


#5

Couldn't be bothered, @james.rhea. Replies are not deserved.


#6

Its not that i couldnt be bothered, I tried but i didnt get the desired outcome.. Why do you think i deleted my previous post?


#7

You gave up too soon. Keep trying until you succeed.


#9

 from random import randint 

board = []

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

def print_board(board):
    for row in board:
        print " ".join(row)

# Add your code below!
from random import randint 

def random_row(board):
    return radint(0, len(board) - 1)
    random_row(board)
    
def random_col(board):
    return radint(0, len(board[0]) - 1)
    random_col(board)

Thank you. I was putting the backticks at the end of my code which is why it wasnt working.


#12

@mtf Still here thank you.


#13

Have you discovered that the two function calls belong outside of the functions, in global scope?


#14

I have & I tried putting the two calls in global scope as follows:

random_col(board)
random_row(board)

but i get the same message


#15

Leave them where they are in global scope, and be sure they are removed from previous. Please let us see your new code (in a new reply). Thank you..


#16

from random import randint 

board = []

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

def print_board(board):
    for row in board:
        print " ".join(row)

# Add your code below!
def random_row(board):
    return radint(0, len(board) - 1)

    
def random_col(board):
    return radint(0, len(board[0]) - 1)
    
   
random_row(board)
random_col(board)

#17

To what are you assigning the return values from the functions?


#18

We assign the return values to ship_row & col_row but we only do that in the exercise after. In this one, they ask us to just call each function on board


#19

Are we good then with the general error correction so we know you have moved on?


#20

The obvious that escapes us all. It happens.


#21

Wow can't believe it.. Thanks so much for the help
Will definitely double check everything before asking for help next time


#22

Never be afraid to ask for help, especially given the path upon which you are embarking.


#24