如何在python字符串中检测更多的单词

时间:2017-06-16 11:16:03

标签: python python-3.x

我正在经历一个例子并且它写了这个东西“检查它们是否是python字符串中的多个项目”

那么如何使用 关键字检查字符串中的多个条目?

示例:

items = input("Enter the name of items: ")
if "table" in items:
      print("Its a table")
           if "chair" in items:
               print("Its a chair")

这个程序可以顺利地处理有桌子和椅子的句子。现在我想要的是输入“输入两个或更多项目”,如果我输入“桌椅沙发”

1 个答案:

答案 0 :(得分:0)

你走了。

  result: number;
  p: number = 0;
  q: number = 0;

  onAdd() {
    this.result = this.p + this.q;
  }