Reputation: 47
For example:
import random
Bandit="B"
List=["","","",""]
Something like this:
import random
List=["","","",""]
List[i]='B'
for i in range(0,2):
print(random.randint(List[i]))
Aka doesn't work
What I want it to print out using for function like:
print["B","","B",""] or ["","B","","B"] and all the other combinations
Upvotes: 0
Views: 52
Reputation: 30
Sorry I can't work out whether you want the program to randomly place the bandit or have it randomly select between the two combinations? Went for the first of the two but if you want the later just say. Hope this helps :)
import random
numb = random.randint(0,3)
bandit = "B"
list = ["","","",""]
list[numb] = bandit
print(list)
Upvotes: 1
Reputation: 1
i am not quite sure why do want to use random function, but since you know where you want 'B' to occur, you can.
List[i] = 'B' # i is an integer, and it is where you want your thing to be
like
List[0] = 'B' # 0 is where a list starts
List[2] = 'B'
result
['B','','B','']
Upvotes: 0