Python Forum
Make Random Choices the same [SOLVED]
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Make Random Choices the same [SOLVED]
#1
Hello everybody,

I wanted to set up a list of strings and print one randomly.
This was really easy to set up:
#Random Variables
myList = ["Example 1", "Example 1", "Example 1", "Example 1"]
random = random.choice(myList)

print(random)
Now since this script (it's of course only an example, my actual script is more complex but I'm only focussing on the important part here) runs twice a day, I want the random choice to be the same if the day is still the same.

For example, if I run this script five times a day I always want it to be example 4 and on another day it should pick another random which stays for this day.
Is it possible to do this and share it with another script or do I need to create some kind of config which stores the daily random-pick ?
Reply


Messages In This Thread
Make Random Choices the same [SOLVED] - by AlphaInc - May-16-2022, 09:17 AM
RE: Make Random Choices the same - by snippsat - May-16-2022, 12:23 PM
RE: Make Random Choices the same - by AlphaInc - May-17-2022, 01:08 PM
RE: Make Random Choices the same - by snippsat - May-17-2022, 01:27 PM
RE: Make Random Choices the same - by AlphaInc - May-17-2022, 01:31 PM
RE: Make Random Choices the same - by snippsat - May-17-2022, 01:41 PM
RE: Make Random Choices the same - by AlphaInc - May-17-2022, 01:43 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Create Choices from .ods file columns cspower 3 716 Dec-28-2023, 09:59 PM
Last Post: deanhystad
  random.choices and random.sample azizrasul 5 2,434 Sep-16-2022, 08:10 PM
Last Post: deanhystad
  Sending random images via smtplib [SOLVED] AlphaInc 0 1,731 Oct-19-2021, 10:10 AM
Last Post: AlphaInc
  optimize choices in multiple if ---: statements Pedroski55 2 2,955 Dec-25-2018, 05:06 AM
Last Post: Pedroski55

Forum Jump:

User Panel Messages

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