The first part of the code is outputting and working correctly, but I am not getting any output from the part about the 2nd for loop. It doesn't give any error either. It's acting like the code doesn't see the for loop.
My main goal is to collect the output of print(record_line)
and print(mostly_line)
in the same array or output.
with open("music_list.txt") as file:
music_tuple = ('ANK','IST')
music_records = file.read().splitlines()
for record_line in music_records:
if record_line.startswith(music_tuple):
print(record_line)
elif record_line.startswish('|'):
mostly_line = music_list.replace('|','')
print(mostly_line)
else:
continue
mostly_line = []
for t in range(len(mostly_line)):
song_name = mostly_line[t][0]
artist = mostly_line[t][1]
info = record_line[t]
print(song_name, artist, info) # I can't see the output of this part
record_line.startswish
) and provide a minimal reproducible example that we can run and reproduce your issue.music_list
is unknown. I would recommend to remove the file reading part and replace it with a simple string or list of lines with sample data. And do not mix double and single quotes. It is up to you which one you use but keep it consistent in your code.