def findSongs(jukeBox):
search = input('Enter a word you want to search in the dataset:')
cnt=0
for artist in jukeBox:
artist = artist.strip().split(',')
if search.lower() in ''.join(artist).lower():
cnt+=1
print('\n\nFound' , cnt, 'matches:\n------------------------\n')
for artist in jukeBox:
artist = artist.strip().split(',')
if search.lower() in ''.join(artist).lower():
printSong(artist[0],artist[1],artist[2],artist[3])
我有代码,将搜索终端输入列表,我想存储匹配的数据到一个列表,这样我就不必搜索一次,以获得一个计数和搜索再次打印。你知道吗
只需在列表中存储匹配的艺术家:
如果您试图实现Memoization,那么这是跟踪历史结果以减少计算并加快程序速度的好方法。下面是关于如何开始的示例代码
相关问题 更多 >
编程相关推荐