+ 1
user input reading in a simple AI using Python3 ...
I am programming a simple AI with P3 , as stated above ... a have made a list and make the AI search the user input for a word from the list ... for instance , the list contains two strings , 'hi' and 'hello' ... but if the user types 'hi there' , how can i make my AI read the 'hi' in it ?
4 Antworten
+ 2
theInput="Hi There".split(" ")
if "Hi" in theInput:
print("the input does contain hi")
elif "There" in theInput:
print("The input contains there")
else:
+ 1
One solution is to include a loop to check for the blank string with a space character : " ". If it matches, then you come out of the loop. Hope this helps :)
+ 1
You're welcome :)
0
ty @Shinjini Ghosh and @Joker 😄 great help !