Question: I have a list as follows:

```
[(1, 3, 0.0), (1, 4, 0.0), (3, 4, 0.0),(1,3,0.8),(1,2,0.8),(1,1,1)]

```

Is there a way to find the elements that all have 0.0 in index 2 of the tuple in an efficient way? So, I would want to make a list 

```
[(1, 3, 0.0), (1, 4, 0.0), (3, 4, 0.0),(1,3,0.8),(1,2,0.8)]

```

I then want to randomly choose one of the 0.0 and one of the 0.8 to keep.

Basically, I want to find a list of duplicates and keep one element from each duplicate based on index 2 in the tuple. 

I wanted more of an efficient solution since there could be hundreds of thousands of elements in the list and many duplicates. I know how to do this inefficiently with for loops, but struggled to think of a very efficient solution. Thanks!

Answer: 
You can start playback of a single file with something like this:

```
var audio = new Audio('audio_file.mp3');
audio.play();

```

If you want to play successive files, you will need to capture the `ended` event, like this:

```
function playFirstTwoFiles() {
    var audio = new Audio('audio_file.mp3');
    audio.addEventListener("ended", playSecondFile, true);
    audio.play();
}

function playSecondFile() {
    var audio = new Audio('audio_file_2.mp3');
    audio.play();
}

```
Refactor your line 5 as follows

```
'<img src="mywebsite/image' + i + '.jpg" onclick="document.getElementById("sound' + i + '").play()"/>'

```