python gives output value of none, when it should be displaying a changed list












0














i am new to python. i am making a game similar to tic-tac-toe, but on a larger scale. i am able to see the grid before user input, but after the user inputs where they want their piece to go the updated grid does not show.
the output will just say none. im thinking my problem is in how im displaying the board, but i am unsure.Please help



print("This is Gomoku Deluxe!")

#starting off with tic-tac-toe

import os

#this is where the code for the game starts
board =

for i in range(19):
board.append(["O"] * 19)


#function to print board
def print_board():
board =
for i in range(19):
board.append(["O"] * 19)
for row in board:
print (row)

#function to place player piece
def drop_point(board, row, col, piece):
board[row][col] = piece

#function checks for empty spot
def valid_location(board, row, col):
return board[row][col] == 0

# this loop handles user's piece
print_board()
turn = 0
game_over = False

while not game_over:
if turn == 0:
row = int(input("Player 1 Select a row: "))
col = int(input("Player 1 Select a col: "))

if valid_location(board, row, col):
drop_point(board, row, col, 1)

else:
row1 = int(input("Player 2 Select a row: "))
col1 = int(input("Player 2 Select a col: "))

if valid_location(board, row1, col1):
drop_point(board, row1, col1, 2)

print_board()

turn += 1
turn = turn % 2









share|improve this question


















  • 1




    What do you mean by "say none"? Is there an error or is the board just unaffected? It might because you are making a new board everytime you print it.
    – Joyal Mathew
    Nov 21 at 3:24










  • The board is unaffected. After a user inputs there spot its supposed to show the board with the given spot marked. Instead it just gives the output None. Im guessing because its reading the zero value as None
    – Billy Jo Dominguez
    Nov 21 at 4:41












  • When I run the program im not getting a None output. The board is unaffected though. Which i'm looking into.
    – Joyal Mathew
    Nov 21 at 15:21
















0














i am new to python. i am making a game similar to tic-tac-toe, but on a larger scale. i am able to see the grid before user input, but after the user inputs where they want their piece to go the updated grid does not show.
the output will just say none. im thinking my problem is in how im displaying the board, but i am unsure.Please help



print("This is Gomoku Deluxe!")

#starting off with tic-tac-toe

import os

#this is where the code for the game starts
board =

for i in range(19):
board.append(["O"] * 19)


#function to print board
def print_board():
board =
for i in range(19):
board.append(["O"] * 19)
for row in board:
print (row)

#function to place player piece
def drop_point(board, row, col, piece):
board[row][col] = piece

#function checks for empty spot
def valid_location(board, row, col):
return board[row][col] == 0

# this loop handles user's piece
print_board()
turn = 0
game_over = False

while not game_over:
if turn == 0:
row = int(input("Player 1 Select a row: "))
col = int(input("Player 1 Select a col: "))

if valid_location(board, row, col):
drop_point(board, row, col, 1)

else:
row1 = int(input("Player 2 Select a row: "))
col1 = int(input("Player 2 Select a col: "))

if valid_location(board, row1, col1):
drop_point(board, row1, col1, 2)

print_board()

turn += 1
turn = turn % 2









share|improve this question


















  • 1




    What do you mean by "say none"? Is there an error or is the board just unaffected? It might because you are making a new board everytime you print it.
    – Joyal Mathew
    Nov 21 at 3:24










  • The board is unaffected. After a user inputs there spot its supposed to show the board with the given spot marked. Instead it just gives the output None. Im guessing because its reading the zero value as None
    – Billy Jo Dominguez
    Nov 21 at 4:41












  • When I run the program im not getting a None output. The board is unaffected though. Which i'm looking into.
    – Joyal Mathew
    Nov 21 at 15:21














0












0








0







i am new to python. i am making a game similar to tic-tac-toe, but on a larger scale. i am able to see the grid before user input, but after the user inputs where they want their piece to go the updated grid does not show.
the output will just say none. im thinking my problem is in how im displaying the board, but i am unsure.Please help



print("This is Gomoku Deluxe!")

#starting off with tic-tac-toe

import os

#this is where the code for the game starts
board =

for i in range(19):
board.append(["O"] * 19)


#function to print board
def print_board():
board =
for i in range(19):
board.append(["O"] * 19)
for row in board:
print (row)

#function to place player piece
def drop_point(board, row, col, piece):
board[row][col] = piece

#function checks for empty spot
def valid_location(board, row, col):
return board[row][col] == 0

# this loop handles user's piece
print_board()
turn = 0
game_over = False

while not game_over:
if turn == 0:
row = int(input("Player 1 Select a row: "))
col = int(input("Player 1 Select a col: "))

if valid_location(board, row, col):
drop_point(board, row, col, 1)

else:
row1 = int(input("Player 2 Select a row: "))
col1 = int(input("Player 2 Select a col: "))

if valid_location(board, row1, col1):
drop_point(board, row1, col1, 2)

print_board()

turn += 1
turn = turn % 2









share|improve this question













i am new to python. i am making a game similar to tic-tac-toe, but on a larger scale. i am able to see the grid before user input, but after the user inputs where they want their piece to go the updated grid does not show.
the output will just say none. im thinking my problem is in how im displaying the board, but i am unsure.Please help



print("This is Gomoku Deluxe!")

#starting off with tic-tac-toe

import os

#this is where the code for the game starts
board =

for i in range(19):
board.append(["O"] * 19)


#function to print board
def print_board():
board =
for i in range(19):
board.append(["O"] * 19)
for row in board:
print (row)

#function to place player piece
def drop_point(board, row, col, piece):
board[row][col] = piece

#function checks for empty spot
def valid_location(board, row, col):
return board[row][col] == 0

# this loop handles user's piece
print_board()
turn = 0
game_over = False

while not game_over:
if turn == 0:
row = int(input("Player 1 Select a row: "))
col = int(input("Player 1 Select a col: "))

if valid_location(board, row, col):
drop_point(board, row, col, 1)

else:
row1 = int(input("Player 2 Select a row: "))
col1 = int(input("Player 2 Select a col: "))

if valid_location(board, row1, col1):
drop_point(board, row1, col1, 2)

print_board()

turn += 1
turn = turn % 2






python






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 21 at 3:18









Billy Jo Dominguez

101




101








  • 1




    What do you mean by "say none"? Is there an error or is the board just unaffected? It might because you are making a new board everytime you print it.
    – Joyal Mathew
    Nov 21 at 3:24










  • The board is unaffected. After a user inputs there spot its supposed to show the board with the given spot marked. Instead it just gives the output None. Im guessing because its reading the zero value as None
    – Billy Jo Dominguez
    Nov 21 at 4:41












  • When I run the program im not getting a None output. The board is unaffected though. Which i'm looking into.
    – Joyal Mathew
    Nov 21 at 15:21














  • 1




    What do you mean by "say none"? Is there an error or is the board just unaffected? It might because you are making a new board everytime you print it.
    – Joyal Mathew
    Nov 21 at 3:24










  • The board is unaffected. After a user inputs there spot its supposed to show the board with the given spot marked. Instead it just gives the output None. Im guessing because its reading the zero value as None
    – Billy Jo Dominguez
    Nov 21 at 4:41












  • When I run the program im not getting a None output. The board is unaffected though. Which i'm looking into.
    – Joyal Mathew
    Nov 21 at 15:21








1




1




What do you mean by "say none"? Is there an error or is the board just unaffected? It might because you are making a new board everytime you print it.
– Joyal Mathew
Nov 21 at 3:24




What do you mean by "say none"? Is there an error or is the board just unaffected? It might because you are making a new board everytime you print it.
– Joyal Mathew
Nov 21 at 3:24












The board is unaffected. After a user inputs there spot its supposed to show the board with the given spot marked. Instead it just gives the output None. Im guessing because its reading the zero value as None
– Billy Jo Dominguez
Nov 21 at 4:41






The board is unaffected. After a user inputs there spot its supposed to show the board with the given spot marked. Instead it just gives the output None. Im guessing because its reading the zero value as None
– Billy Jo Dominguez
Nov 21 at 4:41














When I run the program im not getting a None output. The board is unaffected though. Which i'm looking into.
– Joyal Mathew
Nov 21 at 15:21




When I run the program im not getting a None output. The board is unaffected though. Which i'm looking into.
– Joyal Mathew
Nov 21 at 15:21












1 Answer
1






active

oldest

votes


















0














Ok there were a few errors in your code.



1.) In the valid_location function you were checking if the piece was equal to 0 even though you assigned it as "O"



2.) In the print_board function you were making a new board everytime.



3.) In the drop_point function you were only assigning the value to board inside the function



Here's some new and improved code:



print("This is Gomoku Deluxe!")

#starting off with tic-tac-toe

import os

#this is where the code for the game starts
board =

for i in range(19):
board.append([0] * 19)


#function to print board
def print_board(brd):
for row in brd:
print (row)

#function to place player piece
def drop_point(brd, row, col, piece):
brd[row][col] = piece
return brd

#function checks for empty spot
def valid_location(board, row, col):
return board[row][col] == 0

# this loop handles user's piece
print_board(board)
turn = 0
game_over = False

while not game_over:
if turn == 0:
row = int(input("Player 1 Select a row: "))
col = int(input("Player 1 Select a col: "))

if valid_location(board, row, col):
board = drop_point(board, row, col, 1)

else:
row1 = int(input("Player 2 Select a row: "))
col1 = int(input("Player 2 Select a col: "))

if valid_location(board, row1, col1):
board = drop_point(board, row1, col1, 2)

print_board(board)

turn += 1
turn = turn % 2





share|improve this answer





















  • thanks for the assist... a friend also pointed out the "o" "0" mistake earlier today.
    – Billy Jo Dominguez
    Nov 21 at 17:15











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53404794%2fpython-gives-output-value-of-none-when-it-should-be-displaying-a-changed-list%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Ok there were a few errors in your code.



1.) In the valid_location function you were checking if the piece was equal to 0 even though you assigned it as "O"



2.) In the print_board function you were making a new board everytime.



3.) In the drop_point function you were only assigning the value to board inside the function



Here's some new and improved code:



print("This is Gomoku Deluxe!")

#starting off with tic-tac-toe

import os

#this is where the code for the game starts
board =

for i in range(19):
board.append([0] * 19)


#function to print board
def print_board(brd):
for row in brd:
print (row)

#function to place player piece
def drop_point(brd, row, col, piece):
brd[row][col] = piece
return brd

#function checks for empty spot
def valid_location(board, row, col):
return board[row][col] == 0

# this loop handles user's piece
print_board(board)
turn = 0
game_over = False

while not game_over:
if turn == 0:
row = int(input("Player 1 Select a row: "))
col = int(input("Player 1 Select a col: "))

if valid_location(board, row, col):
board = drop_point(board, row, col, 1)

else:
row1 = int(input("Player 2 Select a row: "))
col1 = int(input("Player 2 Select a col: "))

if valid_location(board, row1, col1):
board = drop_point(board, row1, col1, 2)

print_board(board)

turn += 1
turn = turn % 2





share|improve this answer





















  • thanks for the assist... a friend also pointed out the "o" "0" mistake earlier today.
    – Billy Jo Dominguez
    Nov 21 at 17:15
















0














Ok there were a few errors in your code.



1.) In the valid_location function you were checking if the piece was equal to 0 even though you assigned it as "O"



2.) In the print_board function you were making a new board everytime.



3.) In the drop_point function you were only assigning the value to board inside the function



Here's some new and improved code:



print("This is Gomoku Deluxe!")

#starting off with tic-tac-toe

import os

#this is where the code for the game starts
board =

for i in range(19):
board.append([0] * 19)


#function to print board
def print_board(brd):
for row in brd:
print (row)

#function to place player piece
def drop_point(brd, row, col, piece):
brd[row][col] = piece
return brd

#function checks for empty spot
def valid_location(board, row, col):
return board[row][col] == 0

# this loop handles user's piece
print_board(board)
turn = 0
game_over = False

while not game_over:
if turn == 0:
row = int(input("Player 1 Select a row: "))
col = int(input("Player 1 Select a col: "))

if valid_location(board, row, col):
board = drop_point(board, row, col, 1)

else:
row1 = int(input("Player 2 Select a row: "))
col1 = int(input("Player 2 Select a col: "))

if valid_location(board, row1, col1):
board = drop_point(board, row1, col1, 2)

print_board(board)

turn += 1
turn = turn % 2





share|improve this answer





















  • thanks for the assist... a friend also pointed out the "o" "0" mistake earlier today.
    – Billy Jo Dominguez
    Nov 21 at 17:15














0












0








0






Ok there were a few errors in your code.



1.) In the valid_location function you were checking if the piece was equal to 0 even though you assigned it as "O"



2.) In the print_board function you were making a new board everytime.



3.) In the drop_point function you were only assigning the value to board inside the function



Here's some new and improved code:



print("This is Gomoku Deluxe!")

#starting off with tic-tac-toe

import os

#this is where the code for the game starts
board =

for i in range(19):
board.append([0] * 19)


#function to print board
def print_board(brd):
for row in brd:
print (row)

#function to place player piece
def drop_point(brd, row, col, piece):
brd[row][col] = piece
return brd

#function checks for empty spot
def valid_location(board, row, col):
return board[row][col] == 0

# this loop handles user's piece
print_board(board)
turn = 0
game_over = False

while not game_over:
if turn == 0:
row = int(input("Player 1 Select a row: "))
col = int(input("Player 1 Select a col: "))

if valid_location(board, row, col):
board = drop_point(board, row, col, 1)

else:
row1 = int(input("Player 2 Select a row: "))
col1 = int(input("Player 2 Select a col: "))

if valid_location(board, row1, col1):
board = drop_point(board, row1, col1, 2)

print_board(board)

turn += 1
turn = turn % 2





share|improve this answer












Ok there were a few errors in your code.



1.) In the valid_location function you were checking if the piece was equal to 0 even though you assigned it as "O"



2.) In the print_board function you were making a new board everytime.



3.) In the drop_point function you were only assigning the value to board inside the function



Here's some new and improved code:



print("This is Gomoku Deluxe!")

#starting off with tic-tac-toe

import os

#this is where the code for the game starts
board =

for i in range(19):
board.append([0] * 19)


#function to print board
def print_board(brd):
for row in brd:
print (row)

#function to place player piece
def drop_point(brd, row, col, piece):
brd[row][col] = piece
return brd

#function checks for empty spot
def valid_location(board, row, col):
return board[row][col] == 0

# this loop handles user's piece
print_board(board)
turn = 0
game_over = False

while not game_over:
if turn == 0:
row = int(input("Player 1 Select a row: "))
col = int(input("Player 1 Select a col: "))

if valid_location(board, row, col):
board = drop_point(board, row, col, 1)

else:
row1 = int(input("Player 2 Select a row: "))
col1 = int(input("Player 2 Select a col: "))

if valid_location(board, row1, col1):
board = drop_point(board, row1, col1, 2)

print_board(board)

turn += 1
turn = turn % 2






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 21 at 15:37









Joyal Mathew

317112




317112












  • thanks for the assist... a friend also pointed out the "o" "0" mistake earlier today.
    – Billy Jo Dominguez
    Nov 21 at 17:15


















  • thanks for the assist... a friend also pointed out the "o" "0" mistake earlier today.
    – Billy Jo Dominguez
    Nov 21 at 17:15
















thanks for the assist... a friend also pointed out the "o" "0" mistake earlier today.
– Billy Jo Dominguez
Nov 21 at 17:15




thanks for the assist... a friend also pointed out the "o" "0" mistake earlier today.
– Billy Jo Dominguez
Nov 21 at 17:15


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53404794%2fpython-gives-output-value-of-none-when-it-should-be-displaying-a-changed-list%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Wiesbaden

Marschland

Dieringhausen