I\'m trying to improve a game of battleships. The original version works fine with no errors. I have written code to help overcome the fact that the first version places the shi
Your DisplayChar function does not have a default value. This would do no harm if you'd be handling all possible cases for x
, but apparently you're not. Try
def DisplayChar(x):
if x == 0:
return '?'
elif x == 2:
return 'X'
elif x == 4:
return '*'
else:
return ' '
but this will probably yield blank strings where you don't expect them.
Generally, I'd recommend going through a good Python tutorial first. All of your above code can be greatly simplified.