Greetings to whoever reading this! I have been assigned to make a minesweeper program in python where yeah i could just copy paste an already made one but i wanted to make it myself but I'm having a hard time with my lists here. To make things a little bit more clear i have the main list lets call it List within it i have 10 more lists for the rows of the games board BUT now that i have to add the mines to it i can't find a way to randomly place them around the lists!
x=random.choice(list)
board.replace(x,"nuke",forrow)
-----------------------------------------
x=randrange(len(list))
board.replace(x,"nuke",forrow)
--------------------------------------
x=random.sample(list[i],1)
board.insert(x,"nuke")
----------------------------------------
for x in range(len(list)):
board.insert(random.choice(x),"nuke")
import random
board = [[" "]*10 for i in range(10)]# here i create the big list and the other ones within it
bombs=15#input("Please provide the amount of bombs you want in the game: ")
for list in board: #here is my problem
x=random.sample(list[i],1)
board.insert(x,"nuke")
for x in board:print x
I am expecting anything that is able to help me out on my little program I need something to be able to get the position of X amount of positions in a list and be able to replace them with a "bomb" so call it ! Thanks in advance !!!
Aucun commentaire:
Enregistrer un commentaire