vendredi 12 février 2021

When importing module random error: 'set' object is not subscriptable [duplicate]

Whenever I import the random module get the error message 'set' object is not subscriptable.

Here is the code

import random
from english_words import english_words_set
random.choice(english_words_set)
print(words)
#
word = words
print(word)

When I run this the result is exactly this:

Traceback (most recent call last):
  File "/Users/devahschaefers/PycharmProjects/Hangman/main.py", line 3, in <module>
    random.choice(english_words_set)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/random.py", line 346, in choice
    return seq[self._randbelow(len(seq))]
TypeError: 'set' object is not subscriptable

(this is the one I am talking about)




Aucun commentaire:

Enregistrer un commentaire