-
Notifications
You must be signed in to change notification settings - Fork 0
/
generator.py
executable file
·41 lines (28 loc) · 978 Bytes
/
generator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python
import random
import urllib.request
import subprocess
# Open the file from the URL
with urllib.request.urlopen("https://gist.githubusercontent.com/alexanderwassberg/4614feaf1258c11bec7170ece37db610/raw/b6d68a8f26563cd6b237e67fdc4774887b147ed2/words.txt") as f:
# Read the contents of the URL
data = f.read().decode()
words = data.split("\n")
listA, listB = [], []
for word in words:
split_word = word.split("-")
if len(split_word) == 2:
listA.append(split_word[0])
listB.append(split_word[1])
if listA and listB:
# Choose a random index into each list
indexA = random.randint(0, len(listA) - 1)
indexB = random.randint(0, len(listB) - 1)
# Select the strings at the chosen indices
wordA = listA[indexA]
wordB = listB[indexB]
# Concatenate the strings
combined_string = wordA + "-" + wordB
print(combined_string.capitalize())
#subprocess.run(["figlet", combined_string])
else:
print("Lists are empty")