-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmusic.py
More file actions
185 lines (136 loc) · 5.19 KB
/
music.py
File metadata and controls
185 lines (136 loc) · 5.19 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
import time
import random
myChoice = ["unique taste", "lofty sense", "fly posture", "robust appreciation", "good exposure"]
randomChoice = random.choice(myChoice)
def musicApp():
print("Experience Mocasa. Experience Premium Music.\n")
time.sleep(1)
while True:
username = input("What should we call you? ").title()
# remove extra/unwanted spaces if mistakenly entered by user
username = ' '.join(username.split())
if username:
break
else:
print("\nEmpty input. Please enter your name.\n")
time.sleep(1)
print(f"\nHello, {username}. Tell us a bit about yourself.\n")
time.sleep(1)
while True:
genre = input("1. What's your favorite music genre? ").title()
# remove extra/unwanted spaces if mistakenly entered by user
genre = ' '.join(genre.split())
if genre:
break
else:
print("\nEmpty input. Please tell us your preferred genre.\n")
time.sleep(1)
print(f"\nSeems you've got your grooves on, {username}. More than {random.randint(10, 50)} million of our subscribers vibe to {genre}.\n")
time.sleep(2)
while True:
artiste = input(f"2. Who's your favorite {genre} musical artist? ").title()
# remove extra/unwanted spaces if mistakenly entered by user
artiste = ' '.join(artiste.split())
if artiste:
break
else:
print("\nEmpty input. Please enter the stage name of your favorite artiste.\n")
time.sleep(1)
print(f"\nAwesome! {artiste} is a well celebrated icon in {genre}.\n")
time.sleep(1)
print(f"Now let's see how well you know {artiste}.\n")
time.sleep(1)
print(f"This will be fun, {username}. There are no wrong answers.\n")
time.sleep(1)
while True:
fullname = input(f"3. What's {artiste}'s full name? ").title()
# remove extra/unwanted spaces if mistakenly entered by user
fullname = ' '.join(fullname.split())
if fullname:
break
else:
print("\nEmpty input. Please enter the full name of artiste.\n")
time.sleep(1)
print(f"\nHehehe, you're slowly but surely proving to be a great fan of {artiste}.\n")
time.sleep(1)
while True:
nickname = input(f"4. What's {artiste}'s nick name? ").title()
# remove extra/unwanted spaces if mistakenly entered by user
nickname = ' '.join(nickname.split())
if nickname:
break
else:
print("\nEmpty input. Please enter the nickname of artiste.\n")
time.sleep(1)
print(f"\nNo jokes, you're doing well. I'm sure {artiste} would be proud.\n")
time.sleep(1)
while True:
country = input(f"5. What nationality is {artiste}? ").title()
# remove extra/unwanted spaces if mistakenly entered by user
country = ' '.join(country.split())
if country:
break
else:
print("\nEmpty input. Please enter the nationality of artiste.\n")
time.sleep(1)
print(f"\nInteresting. It's already telling how much you admire {artiste}.\n")
time.sleep(1)
while True:
try:
age = int(input(f"6. How old do you think {artiste} is? ").strip())
break
except ValueError:
print("\nPlease enter a valid number for age.\n")
time.sleep(1)
print(f"\nAwesome. Now let's build you a playlist, {username}.\n")
time.sleep(1)
# playlist function call
playList(username, genre, artiste, fullname, nickname, country, age)
def playList(username, genre, artiste, fullname, nickname, country, age):
while True:
try:
myplaylist = int(input("7. How many albums/tracks do you want to be in your playlist? "))
tracklist = []
break
except ValueError:
print("\nPlease enter a valid number for playlist size.\n")
# add user favorite tracks into tracklist
for song in range(myplaylist):
while True:
track = input("\nEnter album/track name: ").title()
# remove extra/unwanted spaces if mistakenly entered by user
track = ' '.join(track.split())
if track:
tracklist.append(track)
break
else:
print("Please enter a valid non-empty track name.")
print(f"\nWow, your {randomChoice} of music is amazing. You've been ranked in the top {random.randint(3, 10)} of our dopest subscribers.\n")
time.sleep(1)
print(f"You rock, {username}. Your playlist is ready!\n")
time.sleep(4)
# displaylist function call
displayList(username, genre, artiste, fullname, nickname, country, age, tracklist)
def displayList(username, genre, artiste, fullname, nickname, country, age, tracklist):
capitalizeUser = username.upper()
capitalizeArtiste = artiste.upper()
print(f"\t\tWELCOME TO {capitalizeUser}'S MUSIC LIBRARY.\n")
time.sleep(1)
# display user information
userInfo = {
"A. Your favorite genre": genre,
"B. Your favorite artiste": artiste,
"C. Favorite artiste's full name": fullname,
"D. Favorite artiste's nick name": nickname,
f"E. How old is {artiste}?": age,
f"F. What nationality is {artiste}?": country
}
for infoTitle, infoValue in userInfo.items():
print(f"{infoTitle}: {infoValue}\n")
time.sleep(2)
print(f"\t\tYOUR FAVORITE ALBUMS/TRACKS FROM {capitalizeArtiste} ARE: \n")
time.sleep(1)
for index, track in enumerate(tracklist, start=1):
print(f"{index}. {track}\n")
time.sleep(1)
musicApp()