Skip to content Skip to sidebar Skip to footer

Better Way To Write Recursive Random Variables

I know this is really bad, but it works and it was the only way with my current knowledge to complete the job. So I am looking for a 'better' way in practice to write this. Basical

Solution 1:

Just make a function!

def wheel():
    return SLOT_PATTERN[random.randint(0, len(SLOT_PATTERN) - 1)]

And a list of timings:

INTERVALS = [0.25, 0.25, 0.5, 0.75, 1, 1]

Then:

def wheels(n):
    return ' '.join(wheel() for _ in range(n))

if message.content.lower().startswith("!slots"):
    slot = await client.send_message(message.channel, wheels(3))

    for interval in INTERVALS:
        time.sleep(interval)
        slot = await client.edit_message(slot, wheels(3))

Post a Comment for "Better Way To Write Recursive Random Variables"