python - How to make random.shuffle truly random? -


so have list:

words = ["games","development","keyboard","speed","typer","anything","alpha","zealous","accurate","basics","shortcut","purpose","window","counter","fortress","modification","computer","science","history","football","basketball","solid","phantom","battlefield","advanced","warfare","download","upload","antidisestablishmentarianism","supercalifragilisticexpialidocious","discombobulation","liberated","assassin","brotherhood","revelation","unity","syndicate","victory"] 

and have shuffles , displays on label:

entry.delete(0, tkinter.end) random.shuffle(words) label.config(text=str(words[1])) timelabel.config(text="time: " + str(time_score)+ "s") 

i'd know how make shuffle random because feels i'm getting same word on , on again despite there being lot in list. maybe there way remove value list once it's been taken can't shown again?

you can try:

import random random_word = random.choice(words) 

to choose random word array. can do:

words.remove(random_word) 

to remove randomly selected word array avoid getting again if want next random word.

edit - answer comment

when run code below i'm getting different word every time. logic looking for?

words = ["games","development","keyboard","speed","typer","anything","alpha","zealous","accurate","basics","shortcut","purpose","window","counter","fortress","modification","computer","science","history","football","basketball","solid","phantom","battlefield","advanced","warfare","download","upload","antidisestablishmentarianism","supercalifragilisticexpialidocious","discombobulation","liberated","assassin","brotherhood","revelation","unity","syndicate","victory"]  import random while words:     random_word = random.choice(words)     print(random_word)     words.remove(random_word) 

Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -