def create_board(r):
print(r, "Create")
board = list()
for i in range(r):
board.append([0 for i in range(7)])
return board
def check_move(board, turn, col, pop):
checkmovestatus = False
print (r, " Check ")
return checkmovestatus
def check_victory(board, turn):
print (r, "Vict" )
vict_gamewinner=0
return vict_gamewinner
def apply_move(board, turn, col, pop):
print (r, "Apply" )
return
def player_turn(board, turn):
checkmovestatus = pop = False
col=1
print (r, "Player" )
checkmovestatus = check_move(board, turn, col, pop)
return col, pop
def menu_one():
r = int(input("Please enter the desired number (5, 6, or 7): "))
return r
def menu_two():
board = create_board(r)
gamewinner = 0
turn=1
col, pop = player_turn(board, turn)
apply_move(board, turn, col, pop)
gamewinner = check_victory(board, turn)
r = menu_one()
menu_two()
**** code combining 2 menu *********
def create_board(r):
print(r, "Create")
board = list()
for i in range(r):
board.append([0 for i in range(7)])
return board
def check_move(board, turn, col, pop):
checkmovestatus = False
print (r, " Check ")
return checkmovestatus
def check_victory(board, turn):
print (r, "Vict" )
vict_gamewinner=0
return vict_gamewinner
def apply_move(board, turn, col, pop):
print (r, "Apply" )
return
def player_turn(board, turn):
checkmovestatus = pop = False
col=1
print (r, "Player" )
checkmovestatus = check_move(board, turn, col, pop)
return col, pop
def menu_one():
r = int(input("Please enter the desired number (5, 6, or 7): "))
board = create_board(r)
gamewinner = 0
turn=1
col, pop = player_turn(board, turn)
apply_move(board, turn, col, pop)
gamewinner = check_victory(board, turn)
menu_one()
Code - 2 ( I am trying to combine 2 functions into 1 . Variable r from Function 1 ( in code 1) is not accessible from others functions when i am try to combine both functions into 1 - not sure why . How to combine this in single menu , ( Declaring Global - is not the option, also don’t want to pass this variable to various functions )