-1
我对此代码有问题。它将一个字符串分割成一个列表并解析它。当我在列表中标识一个单词时,我想做一些事情。我已经看过IF
语句,尽管它有逻辑意义,但代码只会生成语句“屏幕问题建议”,而不管输入的语句如何。我有点难以理解为什么我不能在条件语句中使用current_word。这有什么明显的错误吗?将字符串拆分为列表并在If语句中使用
text=str(input("enter your problem"))
words = text.split()
for current_word in words:
print(current_word)
if current_word=="screen":
print("screen problem advice")
elif current_word=="power":
print("power_problem advice ")
elif current_word=="wifi":
print("connection_problems advice")
任何意见将不胜感激。
这对我来说很好。请显示一个您认为不正确的示例输入输出对。 –