Python | Band Pick

/ 7 Jul 2013 /
This is my sixth program and the one where I learned how to print text files, the program runs perfectly in the python idle, but only executes if 2 is chosen in the cmd window. If you want to try it out, just make text files with names similar to the ones in the code and put them in the same directory, obviously put songs in them, or whatever you like, what ever format they are in the text file (spacing, etc) is the way they will be printed when executed.


 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
def tend():
    f = open ("rotf.txt")
    data = f.read()
    print(data)
    
    
def ff():
    f = open ("ff.txt")
    data = f.read()
    print(data)
    

def as1():
    f = open("as.txt")
    data = f.read()
    print(data)
    

    
print('''1) Tenacious D
2) Foo Fighters
3) Aerosmith
''')
while 1:
    print(' ')
    band = int(input("Choose your favourite band:  "))
    if band == 1:
        print(' ')
        tend()
        
    elif band == 2:
        print(' ')
        ff()
        
    elif band == 3:
        print(' ')
        as1()
    else:
        print('Sorry what?')
 
Copyright © 2010 M(ath)+me, All rights reserved