I have a problem with this code. It splits a string into a list and parses through it .I want to do something when I identify a word in the list. I have looked at IF statements and although it makes logical sense the code only produces the statement "screen problem advice" regardless of the sentence inputted. I am a bit stumped as to why i cant use current_word in a conditional statement. Is there something obviously wrong with this?
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")
Any advice would be much appreciated.
Aucun commentaire:
Enregistrer un commentaire