import random
twoDimMap = [["H", "-", "-", "-", "-", "-"], ["-", "-", "-", "-", "-", "-"],
["-", "-", "-", "-", "-", "-"], ["-", "-", "-", "-", "-", "-"],
["-", "-", "-", "-", "-", "-"], ["-", "-", "-", "-", "-", "-"]]
items = 0
while items <= 4:
test = random.randrange(0, 3)
if test == 0:
twoDimMap[random.randrange(0, 5)][random.randrange(0, 5)] = "S"
if test == 1:
twoDimMap[random.randrange(0, 5)][random.randrange(0, 5)] = "R"
if test == 2:
twoDimMap[random.randrange(0, 5)][random.randrange(0, 5)] = "*"
# I couldn't think of an easier way to do this
if twoDimMap[0][0] != "H":
twoDimMap[0][0] = "H"
items -= 1
items += 1
print(twoDimMap)
Title explains it all pretty much (even though I know it isn't too descriptive :/), I am trying to make a game where the hero starts on the map at position [0],[0]. I can't work out why the hell I'm sometimes generating fewer items than other times.
Edit: Thanks for all of your feedback, and sorry for wasting your time with my stupid mistake :/. I'm going to blame it on the lack of coffee.