This is my code for file_1:
type_Of_word = [
'movies',
'animals',
'characters'
]
movies = [
'Thor',
'Tangled',
'Forzen',
'Spider-Man: No Way Home'
]
animals = [
'Zebra',
'Porcupine'
]
characters = [
'Mickey Mouse',
'Loki Odinson'
]
And my code for file_2:
import random
import gile_1
word = None
def get_word():
type_of_word_choice = random.choice(file_1.type_Of_word)
global word
word = random.choice(file_1.type_Of_word_choice)
print(word)
What I want to do is to use the name of the type stored in 'type_of_word_choice' and call the specific variable with the list of names and get the random choice of word.
But when I run this, it tells me:
Traceback (most recent call last):
File "c:\Users\aisha\.codeVS\hangman\firstHangman.py", line 95, in <module>
get_word()
File "c:\Users\aisha\.codeVS\hangman\firstHangman.py", line 9, in get_word
word = random.choice(words.type_Of_word_choice)
AttributeError: module 'words' has no attribute 'type_Of_word_choice'
Do you know how to solve this?
movies,animalsandcharacterswould be keys.type_Of_word_choiceisn't defined in file 1 (which I assume is namedwords.py)