Hello i'm new to programming and I have a problem with Python. For a minesweeper I want to create a method in the class bomb in order to place bombs randomly in a array so that's what i wrote :
from random import randint
import numpy as np
a = np.zeros((9, 9), dtype="i")
print(a)
class bomb:
def __init__(self, nb):
self.nb = nb
def init_bomb(self, nb):
i = 0
for i in range(0, nb):
x = randint(0,8)
y = randint(0,8)
a[x,y] = 9
bomb.init_bomb(10)
print(a)
When i run the code i get this error :
TypeError: init_bomb() missing 1 required positional argument: 'nb'
I don't understand why this nb because i wrote the nb that i want in between the parenthesis :
bomb.init_bomb(10)