class stat:
def __init__(self, line):
self.genre = line[1]
self.member = line[2]
self.album = line[3]
self.like = int(line[6])
self.stat = []
self.total = 0
def like_sub(self.line):
a = stat(self, line)
self.stat.append(a)
self.total += a.get_subtotals()
def genre_stat(self):
for a in self.genre:
a.print()
print(f'{self.genre} \n{self.like}')
def member_stat(self):
a = 0
return a + self.like
print(a)
def album_stat(self):
a = 0
return a + self.like
print(a)
def bts_list(filename):
with open(filename, encoding = 'UTF-8') as f:
slist = [stat(line.split(',')) for line in f]
return slist
btslist = bts_list('bts.txt')
def stat_genre():
for s in btslist:
s.genre_stat()
def stat_album():
for s in btslist:
s.album_stat
def stat_member():
for s in btslist:
s.album_stat
Creating search program code using class
I tried my best to make the chords on top The txt file is
If you select a genre,
Dance / GoodA total of 1,000 songs / A total of several songs / GoodAverage: 400
JPOP / GoodTotal: 932 / All rightAverage: 300
If you select by album,
#1 album / GoodTotal:-- / A few songs in total. / GoodAverage:--
Album number two. / GoodTotal:-- / A few songs in total. / GoodAverage:--
If you select a member,
Jin / GoodTotal:-- / A few songs in total. / GoodAverage:--
Jimin/ GoodTotal:-- / A few songs in total. / GoodAverage:--
I want to make it come out like this What should I do to make it look like that?
The professor didn't tell me about Python's first time, but he just threw it and told me to try it ㅠ<
It's not a task or anything, but I really want to make it.
© 2024 OneMinuteCode. All rights reserved.