我是 Python 的新手,正在尝试边做边学,并开始了我的第一个真正的项目。甚至不到 4 小时,我就遇到了一个巨大的障碍。我正在尝试配对可能的输入变体,以便我可以使用该输入来引用字典。不知道这是否可能,并且无法使用参考资料弄清楚。如果可能的话,我什至可以远程关闭吗?
yeast_check = ['lalvin', 'zymaflore', 'actiflore', 'redstar', ' ', 'fermemtis', 'lallemand', 'safale', 'bourgoblanc', 'bourgorouge', 'k1','icv', '-']
yeast_input = input('enter yeast type:')
def yeast_convert(yeast_input):
for check in list(yeast_check):
yeast_input = yeast_input.replace(check, '')
return yeast_input
答案 0 :(得分:0)
yeast_check = ['lalvin', 'zymaflore', 'actiflore', 'redstar', ' ', 'fermemtis', 'lallemand', 'safale', 'bourgoblanc', 'bourgorouge', 'k1','icv', '-']
yeast_input = input('enter yeast type:')
def yeast_convert(yeast_input):
for check in list(yeast_check):
yeast_input = yeast_input.replace(check, '')
return yeast_input
print(yeast_convert(yeast_input))
尝试在 for 循环之后调用它