@FrankZhang6/

Tune Selector

Python

select tune for jam

fork
loading
Files
  • main.py
  • new.txt
  • old.txt
  • preserve.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import random

def pullTunes():
  newList = open("new.txt", 'r').readlines()
  for index in range(len(newList)):
    newList[index] = newList[index][0:len(newList[index])-1]
  oldList = open('old.txt', 'r').readlines()
  for index in range(len(oldList)):
    oldList[index] = oldList[index][0:len(oldList[index])-1]
  tunes = random.sample(newList, 4)
  for tune in tunes:
    newList.remove(tune)
    oldList.append(tune)
    print(tune)
  choice = input("Choice tune: ")
  choosing = False
  while choosing == False:
    if choice == "none" or choice == "None" or choice == "n/a":
      choosing = True
    elif choice in oldList:
      choice = input("This song was already played, choose a new one: ")
    elif choice in newList:
      oldList.append(choice)
      newList.remove(choice)
      print(choice + " added")
      choosing = True
    else:
      print("You have entered " + choice + ", which is not currently in the system.")
      ans = input("Is this correct?: ")
      if ans == "yes" or ans == "y" or ans == "Yes" or ans == "Y":
        oldList.append(choice)
      choosing = True
  new = ""
  old = ""
  for tune in newList:
    new += tune
    new += "\n"
  for tune in oldList:
    old += tune
    old += "\n"
  with open('new.txt','w') as doc1:
    doc1.write(new)
  with open('old.txt','w') as doc2:
    doc2.write(old)
    
def refreshList():
  newList = open('new.txt', 'r').readlines()
  oldList = open('old.txt', 'r').readlines()
  for item in oldList:
    newList.append(item)
  with open('new.txt', 'w') as new:
    for tune in newList:
      new.write(tune)
  with open('old.txt', 'w') as old:
    old.write('')

def readFile(fileName):
  with open(fileName, 'r') as doc:
    for item in doc:
      print(item)