Basically what i want my code to do is to print out 5 'wrong()' func's without there being 2 in the row of the same text. And of course i don't want it to be by luck :)
Though don't worry about the part of it printing out 5 wrong()'s, i just want to make sure if i use this function at least twice i am 100% sure the previous value wont be the same as the next.
For example
What i want to avoid: Wrong! Wrong!
Though this is still fine: Wrong! Incorrect! Wrong!
My Code:
import random
def wrong():
wrong_stats=["\n Wrong!","\n Tough Luck!","\n Better Luck Next Time!","\n Not there yet!","\n Incorrect!"]
rand = random.choice(wrong_stats)
rand3 = random.choice(wrong_stats)
norep(rand,rand3,wrong_stats)
def norep(rand,rand3,wrong_stats):
if rand == rand3:
same = True
while same:
rand = random.choice(wrong_stats)
if rand != rand3:
print(rand)
break
elif rand != rand3:
print(rand)
wrong()
wrong()
wrong()
wrong()
wrong()
Thanks for reading!
Aucun commentaire:
Enregistrer un commentaire