Not again!


I have pasted code created my me for Not again section. My code is executing successfully, but I dont believe this is going to work as intended. As per me, unless the previous column and row value for X is saved somehwere, we are never going to get an answer that "You guessed that one already." I was skeptic about my code.
But when i started doing Play it Sam, i saw a similar code as mine and now i'm thinking their is something completely wrong. Can someone help me here and point out where I went wrong or acknowledge my concern is valid and code is never going to print "You missed my battleship!"

if guess_row==ship_row and guess_col==ship_col:
    print "Congratulations! You sank my battleship!"
    if guess_row not in range(0,5) or guess_col not in range(0,5):
        print "Oops, that's not even in the ocean."
    elif board[guess_row][guess_col]=='X':
        print "You guessed that one already."
        print "You missed my battleship!"
        print print_board(board)


you will add a loop later, then this becomes valuable.

We can't do all steps in a single exercises


Thank you. I think I should have a little more patient.


Judging by your answer, is this a better way to code conditions like this? My thinking is that the condition of obtaining "X" in the board should come first before "You guessed that one already". Please clarify...


what does this refer to?

obtaining X? please clarify with code samples


If my understanding is correct, the code requires a player to guess and do not repeat the same guess. Therefore, my thinking is that the initial guess condition should come first before checking if the guess has been attempted before.


initial guess condition? please clarify your question with code, otherwise its impossible for me to tell what you are refering to, how it currently is, and how you think it should be


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.