dimanche 5 avril 2020

How do i add weight to specific items when performing a random generator?

Starting a movie club with my friends and want to randomly generate a movie from the list. Some of these movies however, none of have seen and i would like for these items to have more weight when selecting. Thanks in advance.

import random

    movies = ["Tron (1982)", "JoJo Rabbit", "12 Angry Men", "Contagion", "once upon a time in hollywood",
      "the prestige", "Lighthouse","Annihiliation","Face/Off (saw this but it’s fun as hell)",
      "Airplane","monty python and the holy grail", "2001 Space odyssey", "Enter the dragon", "cool hand Luke", "lost in translation",
      "Ballad of narayama","One flew over the cuckoos nest", "The green mile", "North by northwest",
      "coco", "the french connection", "Clerks","Scarface","Lawrence of Arabia","This is spinal tap",
      "spaceballs", "brothers grimsby", "This is the end", "Bachelor Party (tom hanks)","Blazing Saddles"
      ,"The Jerk"]
    print(random.choice(movies))



Aucun commentaire:

Enregistrer un commentaire