-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget-quote.py
More file actions
38 lines (30 loc) · 732 Bytes
/
Copy pathget-quote.py
File metadata and controls
38 lines (30 loc) · 732 Bytes
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
import random
def primary():
#print("Keep it logically awesome.")
f = open("quotes.txt")
quotes = f.readlines()
f.close()
numQuotes = random.randint(0, len(quotes))
mySet = set()
i = 0
while len(mySet) < numQuotes:
last = len(quotes) - 1
rnd = random.randint(0, last)
quote = quotes[rnd].rstrip()
if quote not in mySet:
print(quote)
mySet.add(quote)
i += 1
def writeQuote(quote):
f = open("quotes.txt","a")
f.write(quote)
f.close()
if __name__ == "__main__":
print("Please enter a new quote")
try:
quote = input()
except:
quote: None
if quote != '' and quote != None:
writeQuote(quote)
primary()