Python Forum
beginner attempting to make chatbot
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
beginner attempting to make chatbot
#2
You just need to enter "exactly" what the if statement is expecting. In this case "Yes." That's capital "Y" and "period". You would do well to study ways to bullet proof your input. Anyway, here is working code.
print("Does she monitor it?")
c2 = input()
if c2 == "Yes.":
	print("So she must know about me.")
elif c2 == "No.":
	print("Does she know about me?")
c3 = input()
if c3 == "Yes.":
	print("Of course. What does she think? About how you have a version of her in your computer?")
if c3 == "No":
	print("Strange. How?")
Also, try this out:
def check_user_answer (input_string: str) -> str :
	no = ['No', 'no', 'N', 'n']
	yes = ['Yes', 'yes', 'Y', 'y']
	if input_string in no :
		return 'no'
	if input_string in yes :
		return 'yes'
	return 'error'

answer = 'error'
while answer == 'error' :
	test_answer = input ('Does she monitor it? ')
	answer = check_user_answer (test_answer)
if answer == 'yes' :
	print("So she must know about me.")
if answer == 'no' :

	answer = 'error'
	while answer == 'error' :
		test_answer = input ("Does she know about me?")
		answer = check_user_answer (test_answer)
	if answer == 'yes' :
		print('Of course. What does she think? About how', end = '')
		print (' you have a version of her in your computer?')
	if answer == 'no' :
		print ('Strange. How?')
Output:
Does she monitor it? n Does she know about me?y Of course. What does she think? About how you have a version of her in your computer?
Reply


Messages In This Thread
RE: beginner attempting to make chatbot - by BashBedlam - Feb-02-2022, 10:24 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Need Assistance with Creating an AI Chatbot for Client's Website LauraB 3 328 Jun-05-2024, 10:57 PM
Last Post: sawtooth500
  Attempting to read keyboard outside of console Jimmy998 5 1,551 Nov-25-2022, 08:17 PM
Last Post: Larz60+
  Help with simple nltk Chatbot Extra 3 2,094 Jan-02-2022, 07:50 AM
Last Post: bepammoifoge
  Python Reminder MSTeams Chatbot ajaymedidi 0 1,226 Sep-16-2021, 07:13 AM
Last Post: ajaymedidi
  Newbie to Python (Attempting to install DJango on a VPS) jarjar95 0 1,597 May-04-2021, 03:51 PM
Last Post: jarjar95
  Generate questions from excel to test my chatbot mcubac08 5 3,058 Sep-01-2020, 06:15 PM
Last Post: mcubac08
  List index out of range error when attempting to make a basic shift code djwilson0495 4 3,209 Aug-16-2020, 08:56 PM
Last Post: deanhystad
  Trying to pass an exe filepath to tkinter Chatbot & expecting the chatbot to run it svkroy 0 1,657 Jul-16-2020, 07:46 AM
Last Post: svkroy
  Chatbot metro17 2 14,715 Sep-21-2019, 02:05 PM
Last Post: Larz60+
  Invalid archive error when attempting to install dash bootstrap components meaydemi 0 4,874 Jul-11-2019, 05:49 PM
Last Post: meaydemi

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020