Python unkown infinite loop
So currently I'm doing a programming course and I'm stuck on this
question. When I click submit it says there is an infinite loop, I've
tested this for hours on and end and can't seem to find it... if you can
help me I will be so happy :D
import re
text = ""
print("Hello, my name is Eliza. What would you like to talk about?")
while text != "go away":
if text != "go away":
text = input()
text = text.lower()
if re.search(r"\bfeel\b", text) is not None:
print("Do you often feel that way?")
elif re.search(r"\bi am\b", text) is not None:
m = str(re.findall('i am\w* (\w+)',text))
m = re.sub('[\'\]\[]', '', m)
print("How long have you been",m+"?")
elif "you" in text:
if "me" in text:
m = str(re.findall('you\w* (\w.*)',text))
m = m.replace("me","you")
m = re.sub('[\'?\]\[]', '', m)
print("What makes you think I",m+"?")
else:
print("Please go on")
elif text == "go away":
text = "go away"
break
else:
print("Please go on")
else:
text = "go away"
print("I hope I have helped you!")
This is the error it gives me. Your program produced too much output! This
is probably because of an infinite loop in your code.
No comments:
Post a Comment