# This program will pick an artist from a text file import random import time import webbrowser import urllib.parse musicChecked = 0 # You can get rid of the next 4 lines isfilethere = input('Is a text file created already[y/n]? >> ') if isfilethere == 'y': whatisnameoffile = input('Enter the exact name of the file with .txt >> ') print('If the file is empty, nothing will appear.') # If you got rid of the 4 lines above, be sure to correctly fix the layout while True: print("\n") # If you got rid of the 4 lines, make 'whatisnameoffile' to '[insert file name here.txt]' file = open(whatisnameoffile, 'r') line = random.choice(file.readlines()) print("----------------------------------------------") print("Band/Artist: ", line) musicChecked = musicChecked + 1 print("You checked out " + str(musicChecked) + " band(s)/artist(s)") openpage = input('\nWant to open the artist page on last.fm? >> ') if openpage == 'y': url = urllib.parse.urljoin('http://www.last.fm/music/',line) webbrowser.open(url) elif openpage == 'n': pass time.sleep(.5) again = input("\nAgain? >> ") print("----------------------------------------------") if again == "end": print("ok") break # Finally, if you got rid of the 4 lines, you can get rid of everything below elif isfilethere == 'n': nameoffile = input('Name the file and add .txt at the end >> ') time.sleep(1) file = open(nameoffile, 'w') file.write('One item per line.') file.close() print('Edit the file with the artists and run the program again.') else: print('N/A')