Untitled

 avatar
unknown
plain_text
2 years ago
544 B
4
Indexable
import random

# List of example songs
songs = [
    "Song 1 - Artist 1",
    "Song 2 - Artist 2",
    "Song 3 - Artist 3",
    "Song 4 - Artist 4",
    "Song 5 - Artist 5",
]

def find_random_song(song_list):
    # Generate a random index within the range of the list
    random_index = random.randint(0, len(song_list) - 1)
    
    # Retrieve the random song
    random_song = song_list[random_index]
    
    return random_song

# Example usage
random_song = find_random_song(songs)
print("Random Song: ", random_song)
Editor is loading...