Python-making-a-beep-noise-using-loop

-1

I need to write a program that plays the song “Little Jonathan” for that, I have to create iterable from the string of notes and run it for loop, or alternatively use the next function

In order to play a song, we need to know its frequency and how long it should play. To do this, use the following two variables:

  • A dictionary called freqs
freqs = {"la": 220,
 "si": 247,
 "do": 261,
 "re": 293,
 "mi": 329,
 "fa": 349,
 "sun": 392,
 }

Strings that include the song notes:

  • notes = "solar, 250-mi, 250-mi, 500-fa, 250-re, 250-re, 500-do, 250-re, 250-mi, 250-fa, 250-solar, 250-solar, 250-solar , 500 " A comma appears after each character, followed by a number representing the length of time the character should play. Each character is separated by a dash.

I’m supposed to use the split method to split the character strings by the hyphen. In order to play a character, I should use the following skeleton code:

import winsound
...
winsound.Beep (frequency, duration)

The Beep function receives two parameters: the frequency of a character and the length of time to be played. #that is my code so far - how can i complete the missine to play the song according to the node string

    def Beep(frequency, duration)
#Strings that include the song notes
notes_of_song   = 'sol,250-mi,250-mi,500-fa,250-re,250-re,500-do,250-re,250-mi,250-fa,250-sol,250-sol,250-sol,500'
# Splitting at ':'
x=(notes_of_song.split(','))
freqs = {"la": 220, # dictionary with freqs of the keys  the values are numbers that represent frequencies
         "si": 247,
         "do": 261,
         "re": 293,
         "mi": 329,
         "fa": 349,
         "sol": 392,
         }
import winsound
for i in word:
    ןif i in
    iter i from freqs

winsound.Beep(frequency, duration)

Help How can I complete this task? Put together the song