Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Randomize in tables
#2
Try random.choice() or random.choices()

Maybe read up on weights=, I don't understand it! k=5 gives you 5 results

import random

mylist = ["apple", "banana", "mango", "cherry", "pear", "raspberry"]
print(random.choices(mylist, weights = None, k = 5))
Reply


Messages In This Thread
Randomize in tables - by mariavol - Aug-15-2022, 07:46 AM
RE: Randomize in tables - by Pedroski55 - Aug-15-2022, 10:29 AM
RE: Randomize in tables - by mariavol - Aug-15-2022, 02:36 PM
RE: Randomize in tables - by deanhystad - Aug-15-2022, 09:23 PM
RE: Randomize in tables - by Pedroski55 - Aug-15-2022, 11:30 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020