diff options
author | Anthony Wang | 2022-02-23 15:08:42 -0600 |
---|---|---|
committer | Anthony Wang | 2022-02-23 15:08:42 -0600 |
commit | cc60315e2105773dc045de3433ba92d5ee88688f (patch) | |
tree | c6a148997a9d332862c3cdb78b8479f50e21e9bd | |
parent | b93fb7b7776eba44d0fc4d7feaae1521b9936b56 (diff) |
Make sure that the randomly chosen line has at least two words
-rw-r--r-- | bot.py | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -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] |