He Guys,
i need to counter balance my words for an experiment in Python. As I am a bit new in Python, I don't know how to solve the following problem:
Function:
import random
def counterbalance(wordlist):
count = 0
wordlist_new = []
for word in wordlist:
wordlist_new.append(random.choice(wordlist))
count += 1
if count == 0:
break
return wordlist_new
wordlist = ["Bati", "Uteli", "Foki", "Ipe", "Asemo", "Ragi", "Bilu", "Oga", "Egi", "Tidu", "Pewo", "Elebo", "Dalo",
"Bofe","Tari", "Zega", "Atesi", "Teku", "Doza", "Bani"]
print(counterbalance(wordlist))
I want 10 words in a new list that differ from each other and I need to do this 6 times. There can only be no duplicates in the new list of words. So no "Bati" and "Bati" in the same list.
Aucun commentaire:
Enregistrer un commentaire