如果在Python中语法错误

时间:2016-08-04 21:21:39

标签: python

petname = ['Zophie', 'Pooka', 'Fat-tail'];\
  print ('what is your pets name?');\
  name = input();\
  if name not in petname:;\

我上面的代码出现语法错误?有人可以帮忙吗

1 个答案:

答案 0 :(得分:1)

你需要这样做,如果我认为这是你的目的是正确的:

petname = ['Zophie', 'Pooka', 'Fat-tail']
print ('What is your pets name?')
name = input()
if name not in petname:
    print ('Your pet is not in the list')
else:
    print ('Your pet is in the list')