O
2

Question about a weird bug with the ask function in a Python script

I built a simple Q&A bot last month that uses a basic ask function. It kept throwing a 'NoneType' error when someone typed nothing and just hit enter. I thought it was a quick fix, maybe ten minutes. I spent three hours checking the input line, the logic, even the way the terminal handled empty strings. Turns out I needed to add a strip() method and a while loop to catch blank replies. Has anyone else hit this with raw_input or input in Python 3?
3 comments

Log in to join the discussion

Log In
3 Comments
joseph_adams66
Ever think about how many bots fail because they don't plan for people just hitting enter?
5
reesemoore
reesemoore16d ago
But what if that's the real test? A good bot should handle blank input as a normal case. It just shows who built it with real users in mind.
6
blake322
blake32214d ago
That blank input trap is a classic. Honestly, it feels more like a basic oversight than a real user test. Just seems like something you fix once and forget about.
0