repl.it
@_Sniper_Turtle_/

City Name Chooser

Python

No description

fork
loading
Files
  • main.py
  • StreetNames.txt
  • StreetNamesNoMore.txt
main.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
42
43
from random import randint as r
from replit import clear as c
c()
f=open('StreetNamesNoMore.txt','w+')
f.write('')
f.close()
def clen(x):
  return len(x)-1
streetStarts=['New','Old','Green','Red','Blue','Yellow']
streetEnds=['street','avenue','boulevard','court','terrace','drive','lane']
with open('StreetNames.txt', 'r') as f:
    streetNames = f.readlines()
def printStuff():
  if len(streetNames) < 1:
    print('You are DONE!')
    while True==True:
      nextThing=input('')
  start='start'
  streetStart=r(0,len(streetStarts)*3)
  if streetStart > clen(streetStarts):
    start=''
  chosen=r(0,clen(streetNames))
  if start == 'start':
    start=streetStarts[streetStart]
  streetName=start+' '+streetNames[chosen]+' '+streetEnds[r(0,clen(streetEnds))]
  f=open('StreetNamesNoMore.txt','r')
  lines = f.readlines()
  streetNamesNotAllowed=f.read()
  #BlacklistedStreets = ' '.join([line.strip() for line in lines])
  #print(BlacklistedStreets)
  f.close()
  if streetName not in streetNamesNotAllowed:#BlacklistedStreets
    print(streetName)
    f=open('StreetNamesNoMore.txt','a')
    f.write(streetName)
    f.close()
  else:
    printStuff()
def looper():
  printStuff()
  foo=input('')
  looper()
looper()
?