修复错误“在<string>中”要求将字符串作为左操作数,而不是元组

时间:2019-03-29 19:05:00

标签: python string tuples

我将实现一个简单的程序,该程序将根据您的提示来猜测您在可用单词中选择了哪个单词。到目前为止,这是我所做的:

new Vue({
  el: "#app",
  mounted() {
    setTimeout(() => {
      var newScript = document.createElement("script");      
      newScript.setAttribute('src', 'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js');
      var message = document.createElement("script");
      var alert = document.createTextNode("alert('Added jQuery Script Tag!');");
      message.appendChild(alert);
      document.body.appendChild(newScript);
      document.body.appendChild(message);
    }, 2000);
  }
});

现在,我被卡在了熊猫上,并引发了以下错误:

print('you have 2 words you can give hints of, Panda, or bucket ')
term = ('china','chinese','bamboo','bear','panda','black','white',
        'black and white','cute','adorable','big','ying and yang')
hint1 =input('Give me a hint   ')
if term in hint1:
    print('I think it is a panda!')

有人可以帮我吗?

1 个答案:

答案 0 :(得分:1)

您只需要在if语句中翻转变量的顺序即可:

print('you have 2 words you can give hints of, Panda, or bucket ')
term = ('china','chinese','bamboo','bear','panda','black','white',
        'black and white','cute','adorable','big','ying and yang')

hint1 =input('Give me a hint ')
if hint1 in term:
    print('I think it is a panda!')