3

I am getting this error "TypeError: 'tuple' object is not callable" whenever I am trying to get a object in tuple. My code is -

import random
import sys

inp = input("Press ENTER to start.")
sys.stdout.write("Rules --\nIn this game, you will have to correctly guess the word. If you can do that successfully, YOU WIN!\n")
sys.stdout.write("You will given (number of letters of the word + 2) chance. In each chance you will have to guess a letter of the word\n")
sys.stdout.write("If you run out of chance, you lose. :(\n")

while True:
    inp = input("Ready(Y/N)? ")
    if 'Y' in inp or 'y' in inp:
        print("Okay")
        break
    elif 'n' in inp or 'N' in inp:
        sys.exit

Word_List = ('banana', 'cat', 'mat', 'apple', 'pineapple', 'mango')
m = random.randint(1, 6)
word = Word_List(m)
chances = len(word) + 2

for x in range(len(word)):
    sys.stdout.write('_ ')

Can anyone spot the error?

1
  • 2
    It needs to be word=Word_List[m] Commented Jul 25, 2021 at 4:12

1 Answer 1

5

Word_List(m) putting a parenthesis indicates python that this is a function. However, you have defined it as a tuple. Hence you get the error .

You have to use square brackets

word=Word_List[m]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.