Jan-07-2018, 11:52 PM
Hi, I am trying to learn python and the book I am reading is having me create this program. This is what i have so far and I am getting an error on line 53 --- 'str' object is not callable. I am not sure what I am doing wrong. Any and all help is appreciated.
# Chapter 4 Program 4 # Computer picks a random word and the player has to guess the word # Computer tells how many letters are in the word # Player gets 5 chances to ask if a letter is in the word. # Computer responds with yes or no # Player must guess the word import random # Introduction print("\nIn this game you must guess a word that a computer randomly generates.", "\n\tThe computer will tell you how many letters are in the word.", "\n\tYou will have 5 chances to ask if a letter is in the word.") input("\n\t\t PRESS ENTER TO BEGIN") # Instert tuple WORDS = ("archer","universe","castle","pretzel","rocky","illinois","programming") # CHECK - DELETE LATER print("Count of WORDS list", len(WORDS)) #--------------------------------------- word = random.choice(WORDS) length = len(word) placeholder = "" print("\nThere are ",length,"letters in the word.") print("\nYou now have 5 chances to ask if a letter is in the word.") print("\nThe computer will respond with 'Yes' or 'No'") print("\n\tUse lower case.") #CHECK - DELETE LATER print("THE WORD IS ------- " , word) #----------------------------- counter = 5 while counter !=0: answer = input("\nWhat is your first guess?") # Calculates if players answer is in the word for i in range(1, length, 1): if answer == word(length): placeholder = "Yes " else: placeholder = "No " print(placeholder)