samedi 29 août 2020

Is there a way to streamline a random.randint script?

I am creating a game where a user must guess a song, I have implemented a notepad document containing a list of popular songs. I have randomised the selection of a song using this

CurrentSong = random.randint(0,39) 
if CurrentSong == 0: 
    CurrentSong = Song[0]
elif CurrentSong == 1:
    CurrentSong = Song[1]

(this repeats for 40 songs) 

Does anyone know of a way to do this in a shorter/more efficient way?

The actual code.




Aucun commentaire:

Enregistrer un commentaire