print = ('Tell me about your pet. ')
about_pet = input()
if 'dog'.lower() in about_pet == True :
print('ah, a dog')
if 'cat'.lower() in about_pet == True :
print ('ooh, a kitty')
print ('Thanks for the story')
当我运行此代码时,我收到一个错误:
str对象不可调用
是什么导致这个?
print = ('Tell me about your pet. ')
将函数print
覆盖为字符串。之后它不再是一个函数,所以每次你试图将它作为函数调用时,你都会遇到错误。
摆脱=
所以你不会改变print
是什么。