Issue
So im trying to make a conversation generator in python using the fashion of an AI where the user will say something like 'hi' and then the machine replies 'hello how are you' and as you can guess, this will need alot of user input but every time i input ANYTHING, i get the output:
Traceback (most recent call last):
File "main.py", line 4, in <module>
talk=input('')
File "<string>", line 1, in <module>
NameError: name '___' is not defined
heres my code:
#Modules
import os
#Getting User Input
talk=input('')
#Machine responding
if talk == "Hi":
print('Hey, how are you?')
feeling=input('')
if feeling == "good":
print('Thats good!')
if feeling == "bad":
print('aww thats bad, maybe chatting with me will help?')
#Restarting The script
os.system('python main.py')
Just for some extra info, im using python 3 running scripts via ubuntu root terminal All help is greatly appreciated. Thanks.
Solution
I guess you're using python2
to run the script. Try python3
instead.
I'm able to replicate your error by running it with python2
Traceback (most recent call last):
File "temp", line 4, in <module>
talk=input('')
File "<string>", line 1, in <module>
NameError: name 'Hi' is not defined
But success by using python3
Hi
Hey, how are you?
Answered By - Kavin Ruengprateepsang
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.