Here is the code:
import random
def game(rows, colums):
table = (rows * colums - 1) * [' '] + ['bomb']
random.shuffle(table)
while True:
position = input('Enter next position (x, y):')
bombposition = position.split()
if table[int(bombposition[0])*colums + int(bombposition[1])] == 'bomb':
print('you found the bomb!')
break
else:
print('no bomb at', position)
the error:
game(1,0)
Enter next position (x, y):>?
(1,0)
Traceback (most recent call last):
File "input", line 1, in <module>
File "input", line 8, in game
ValueError: invalid literal for int() with base 10: '(1,0)'
Aucun commentaire:
Enregistrer un commentaire