user input reading in a simple AI using Python3 ... | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 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 ?

15th Oct 2017, 6:28 PM
ph4n70m
ph4n70m - avatar
4 Réponses
+ 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:
15th Oct 2017, 6:52 PM
LordHill
LordHill - avatar
+ 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 :)
15th Oct 2017, 6:42 PM
Shinjini Ghosh
+ 1
You're welcome :)
22nd Oct 2017, 5:29 AM
Shinjini Ghosh
0
ty @Shinjini Ghosh and @Joker 😄 great help !
21st Oct 2017, 4:52 PM
ph4n70m
ph4n70m - avatar