hello everyone i have write code and it keep getting an error can someone tell me what is wrong with the code?
file = open("mypiano.txt", 'r+')
slist = []
for line in file.readlines():
value = line.split()
slist.append([value[0],value[1],value[2]])
print(slist)
file.close()
#print(type(slist))
twinkle_list = slist
#print(type(twinkle_list))
from threading import Thread
import pygame as pg
import time
pg.mixer.init()
pg.init()
pg.mixer.set_num_channels(len(twinkle_list))
def play_notes(notePath,duration):
time.sleep(duration)
pg.mixer.Sound(notePath).play()
time.sleep(duration)
print(notePath)
path = ("Sounds/")
cnt = 1
th = {}
for t in twinkle_list :
th[t] = Thread(target = play_notes,args = (path+'{twinkle_list}.ogg'.format(t),0.3))
th[t].start()
th[t].join()
if cnt%7==0:
time.sleep(1)
cnt +=1
the error said like this : Traceback (most recent call last): File "C:/Users/wmeyl/PycharmProjects/DSP/venv/piano_test1.py", line 31, in th[t] = Thread(target = play_notes,args = (path+'{twinkle_list}.ogg'.format(t),0.3)) KeyError: 'twinkle_list'