so how can I loop a function to pull an element at random and if it doesn't meet certain parameters pull a different element?
I'm pretty new to python and honestly coding in general. So let me explain what I'm doing.
The project is basically automating character choice for players one and two. In excel there is a list of characters names, their 'pecking' number, win, lose, ect. I'm using the 'pecking' number to determine what characters are picked.
Each time the program runs it increases all characters pecking number by 1.
It then makes a list of lists that contain all characters names and pecking number.
Then it finds the highest pecking number and places that name as fighter 1. (and picks if there is a tie)
Now (the part I'm stuck on)it pulls a list at random and checks that 1) it isn't fighter 1 and 2) that it's pecking number is above a certain value and makes that player 2.(my way of making it a semi deterministic random)
def another_one(sequence):
item = random.choice(sequence)
if item[0] == fighter_one:
another_one(sequence)
elif item[1] < 20:
another_one(sequence)
else:
new_guy = item
return new_guy
If I'm correct it seems that it is pulling the first "item" at random just fine, but at if it hits the "if" or "elif" it just ends? I don't know. any help would be appreciated.
EDIT: ok so I added a print("if fail") and ("elif fail") to see if it was hitting it and it is printing the "elif fail" line twice. So I think its saying once it is run the first time that 'random' element is now permanent?
Aucun commentaire:
Enregistrer un commentaire