Hello I am trying to get def automated(filename): to read an imported text document and have have it make a playlist based upon the specified genre and playlist time. Example is if you decide upon 20 minutes and blues as a genre, the program randomly chooses songs that total up to 20 minutes as close as possible. There is no sample output as def automated isn't set up and configured yet. For this python program you have to choose a file to open first then run automated song choice. Automated is the one I am trying to get working def automated(filename): try: print(filename) except FileNotFoundError: print('Document not found.') def main(): filename = '' import case print("\n\tPlaylist Manager") print('-'*45) print('\tWhich Program do you want to run?') choice = '' while choice.upper() !='Q': print() print('current file opened:', filename) print('0) choose a file to open') print('1) automated song choice') print('2) Special song choice') print('3) manual song choice') print('4) Current song playing') print('5) Save Song Playlist') print('Q) Quit') choice=input('Enter a choice: ') if choice == '0': print() filename =input('Enter file name: ') print('filename saved as', filename) elif choice == '1': print() automated(filename) elif choice == '2': print() special_song(filename) elif choice == '3': case.manual_choice(filename) elif choice == '4': print() current_song(filename) elif choice == '5': print() save_playlist() elif choice.upper() == 'Q': print("Program complete.") else: print('Invalid choice.') main() contents of imported case.py def manual_choice(filename): try: rfile = open(filename, 'r') line_list =rfile.readlines() for index in range(len(line_list)): line_list[index] =line_list[index].rstrip('\n') for song in line_list: words_list=song.split(' ') song = input('What song are you looking for?: ') if song in rfile: print(song, 'is in the file', filename) else: print(song, 'does not appear to be in the file', filename) except FileNotFoundError: print('there is no such file named', filename) contents of text document Alternative Bastille Pompeii 3:34 Happier 3:34 Of The Night 3:33 Panic! At The Disco I Write Sins Not Tragedies 3:06 Nine in the Afternoon 3:11 High Hopes 3:10 Blues Tab Benoit Nothing Takes The Place Of You 4:01 For What It's Worth 5:17 Shelter Me 5:05 Joe Bonamassa I'll Take Care Of You 5:41 The Heart That Never Waits 5:51 Notches 7:04 Robert Cray Right Next Door (Because of Me) 4:21 Smoking Gun 4:05 This Man 5:06
Hello I am trying to get def automated(filename): to read an imported text document and have have it make a playlist based upon the specified genre and playlist time. Example is if you decide upon 20 minutes and blues as a genre, the program randomly chooses songs that total up to 20 minutes as close as possible. There is no sample output as def automated isn't set up and configured yet. For this python program you have to choose a file to open first then run automated song choice. Automated is the one I am trying to get working
def automated(filename):
try:
print(filename)
except FileNotFoundError:
print('Document not found.')
def main():
filename = ''
import case
print("\n\tPlaylist Manager")
print('-'*45)
print('\tWhich Program do you want to run?')
choice = ''
while choice.upper() !='Q':
print()
print('current file opened:', filename)
print('0) choose a file to open')
print('1) automated song choice')
print('2) Special song choice')
print('3) manual song choice')
print('4) Current song playing')
print('5) Save Song Playlist')
print('Q) Quit')
choice=input('Enter a choice: ')
if choice == '0':
print()
filename =input('Enter file name: ')
print('filename saved as', filename)
elif choice == '1':
print()
automated(filename)
elif choice == '2':
print()
special_song(filename)
elif choice == '3':
case.manual_choice(filename)
elif choice == '4':
print()
current_song(filename)
elif choice == '5':
print()
save_playlist()
elif choice.upper() == 'Q':
print("Program complete.")
else:
print('Invalid choice.')
main()
contents of imported case.py
def manual_choice(filename):
try:
rfile = open(filename, 'r')
line_list =rfile.readlines()
for index in range(len(line_list)):
line_list[index] =line_list[index].rstrip('\n')
for song in line_list:
words_list=song.split(' ')
song = input('What song are you looking for?: ')
if song in rfile:
print(song, 'is in the file', filename)
else:
print(song, 'does not appear to be in the file', filename)
except FileNotFoundError:
print('there is no such file named', filename)
contents of text document
Alternative
Bastille
Pompeii
3:34
Happier
3:34
Of The Night
3:33
Panic! At The Disco
I Write Sins Not Tragedies
3:06
Nine in the Afternoon
3:11
High Hopes
3:10
Blues
Tab Benoit
Nothing Takes The Place Of You
4:01
For What It's Worth
5:17
Shelter Me
5:05
Joe Bonamassa
I'll Take Care Of You
5:41
The Heart That Never Waits
5:51
Notches
7:04
Robert Cray
Right Next Door (Because of Me)
4:21
Smoking Gun
4:05
This Man
5:06
Step by step
Solved in 2 steps