While writing code for Battleship extra credit I ran into a problem trying to check for ship tile duplicates. The issue looks something like this:
def B_setup(): B = [(1,randint(0,3)),(1,randint(0,3))] return B A = [(1, 0), (1, 1), (1, 2)] B = [(1, 0), (1, 1)] for point in B: while point in A: B = B_setup() print B
This outputs nothing and gives me no error to work with. When I try to close the shell it says it’s still running.
B = [(1, 3), (1, 3)]
Because those are the only points that randint can chose from that aren’t in A
Bnew =  for num in range(len(B)): #ensures num relates to B while B[num] in A: B = B_setup() #sets B to a new list which changes B[num] Bnew.append(B[num]) if Bnew != : B = Bnew
I was able to apply this code to my Battleship game. Thank you to post contributors for helping me.