题解 | #下厨房#
下厨房
https://www.nowcoder.com/practice/ca5c9ba9ebac4fd5ae9ba46114b0f476
import sys class solution: def __init__(self): self.food = [] self.material = [] def my_input(self) -> list: # 判断用户输入结束 for line in sys.stdin: tmp = line.split(' ') for i in range(len(tmp)): self.food.append(tmp[i].rstrip()) # 删除每个子字符串末尾的换行符 return self.food def Material(self) -> list: for i in range(len(self.food)): if self.food[i] not in self.material: self.material.append(self.food[i]) return self.material if __name__ == '__main__': my_solution = solution() food = my_solution.my_input() result = my_solution.Material() print(len(result))