I am trying to make a hangman game in python but i get the attribute error in my title. this is my code
I have no idea what might be causing this attribute error in my code. I think it might have something to do with my code not having the correct naming or it might be how i defined in-File
import random
import string
WORDLIST_FILENAME = "words.txt"
def load_words(inFile=0):
"""
Returns a list of valid words. Words are strings of lowercase letters.
Depending on the size of the word list, this function may
take a while to finish.
:param inFile:
"""
print("Loading word list from file...")
# inFile: file
open( words.txt , r )
# line: string
line = inFile.readline()
# wordlist: list of strings
words = line.split()
print(" ", len(words), "words loaded.")
return words
Error:
File "C:)Users ManyDog PycharmProjects hangmanmain.py", line 49, in <module>
wordlist = load_words ()
File "C:)Users ManyDogPycharmProjectshangmanmain.py", line 27, in Load_words
line = inFile. readline ()
AttributeError: int object has no attribute readline