zak100 Posted November 14, 2020 Share Posted November 14, 2020 import pickle,random a=open('lexicon-luke','rb') successorlist=pickle.load(a) a.close() def nextword(a): if a in successorlist: return random.choice(successorlist[a]) else: return 'the' speech='' while speech!='quit': speech=raw_input('>') s=random.choice(speech.split()) response='' while True: neword=nextword(s) response+=' '+neword s=neword if neword[-1] in ',?!.': break print (response) Hi, I got the above code from: https://stackoverflow.com/questions/5306729/how-do-markov-chain-chatbots-work I am getting following error: Quote Traceback (most recent call last): File "/home/zulfi/PycharmProjects/chatbot/MarkovBot.py", line 13, in <module> speech=raw_input('>') NameError: name 'raw_input' is not defined Somebody please guide me how to define raw_input(...)? Zulfi. Link to comment Share on other sites More sharing options...
Sensei Posted November 14, 2020 Share Posted November 14, 2020 You should be well aware by now, after months spend on writing Python, how to solve such basic issues.. Simply enter error or warning message in e.g. Google search engine.. e.g. https://www.google.com/search?q=NameError%3A+name+'raw_input'+is+not+defined and we see the list of people who had exactly the same issue as you in the past. Write it down: use Google search engine. That's what programmers do all day long. Immediately you have answers, without having to wait until somebody will answer your question on the forum here. 1 Link to comment Share on other sites More sharing options...
zak100 Posted November 15, 2020 Author Share Posted November 15, 2020 Hi, Thanks a lot. I thought raw_input(..) is a user-defined function. Thanks it worked by changing raw_input(...) to input(...). Zulfi. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now