为什么总是出现TypeError:“ str”对象不可调用

时间:2019-07-05 20:30:10

标签: python

无论我做什么,我都会不断收到此错误,您能否也给我一些有关我的代码组织和效率的提示?我是个初学者,所以您的帮助对我很重要。 谢谢和问候, 尼尔森

#hangman
import random
print('''Hello there, welcome to hangman game!
If you want to read the rules/intructions type instructions in the box bellow, 
if you want to play type play in the box bellow,
if you want to quit type quit in the box bellow''')
option = input('What do you wanna do: ')

if option[0] is 'i':
    print('''A random word will be selected and partialy hidden 
    and you have to guess the word letter by letter,
    if you misspell the word you will lose a life and you only have 6
    use them wiselly''')
    option = input('What do you wanna do: ')

if option[0] is 'p':
    print = (' Please choose a categorie from animals, jobs, countries and teams')
    categorie = input('Select a categorie: ')

if categorie[0] is 'a':
    list = ["dog", "cat", "elephant", "cheetah"]
    categorie1 = random.choice(list)
    if categorie1[1] is "o":
        print('''Hint: It's considered mans best friend''')

    if categorie1[1] is 'a':
        print('''Hint: It is considered to have 7 lives!''')

    if categorie1[1] is 'l':
        print('''Hint: It is gray and has pretty expensive fangs''')

    if categorie1[1] is 'h':
        print('cheetah')

选择我想要的类别时收到的错误消息是:

`Traceback (most recent call last):
  File "C:/Users/Pc/PycharmProjects/hangman/hangman.py", line 33, in <module>
    print('cheetah')
TypeError: 'str' object is not callable`

我想从列表中打印随机选择的单词,当我找出动物的类型时,我想在其他类别中实现相同的代码

0 个答案:

没有答案