aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Wang2022-02-23 15:08:42 -0600
committerAnthony Wang2022-02-23 15:08:42 -0600
commitcc60315e2105773dc045de3433ba92d5ee88688f (patch)
treec6a148997a9d332862c3cdb78b8479f50e21e9bd
parentb93fb7b7776eba44d0fc4d7feaae1521b9936b56 (diff)
Make sure that the randomly chosen line has at least two words
-rw-r--r--bot.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/bot.py b/bot.py
index ee87ebb..495a22b 100644
--- a/bot.py
+++ b/bot.py
@@ -48,11 +48,16 @@ if args.input is None:
'Breaking news:',
'Have I ever told you that',
'I read on the news that',
- 'I never knew that'
+ 'I never knew that',
+ 'My dream is',
+ 'It\'s terrible that'
])
else:
with open(args.data, 'r') as f:
- line = choice(f.readlines()).split()
+ lines = f.readlines()
+ line = choice(lines).split()
+ while len(line) < 2:
+ line = choice(lines).split()
args.input = line[0] + ' ' + line[1]