I am generating a random word for my Hangman game, and hence want to generate a random word.
I am using the /usr/share/dict/words
file and doing the following:
def word_select():
import os
word = os.system('head -$((${RANDOM} % `wc -l < /usr/share/dict/words` + 1)) /usr/share/dict/words | tail -1')
return word
But when I check the value of word, it has the value 0 (Which is most probably the exit status of the command in round brackets). How do I store the word in my variable?