0

Hi, im trying to figure out how to call a function's variable
from here

def legal_moves(board):
    moves = []
    for square in range(DINNER):
        if board [square] == SPACE:
            moves.append(square)
    return moves

I want to take the variable moves and use it for main

How would I do that?

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by pyTony
0

With

global moves

or by adding moves as one more parameter, which will change the caller's variable as list is mutable.

Or by using legal_moves.moves instead of moves, but that is quite special way, which is not generally practiced.

Edited by pyTony: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.