S
S
shuzzixd2021-07-27 20:26:57
Python
shuzzixd, 2021-07-27 20:26:57

How to make it so that when you click on the button, some message from the list will fly out with a chance?

For example: I click on the open button
Something from the list drops out with some chance
Nothing dropped (65%)
You got 200 currency (25%)
You got 500 currency (10%)
You got 1500 currency (5%)
You got 10000 currency (1%) (changed)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
MinTnt, 2021-07-27
@shuzzixd

import random
ListOfPrize = ["ничего", "200", "100", "50"]

print(random.choices(ListOfPrize, weights=(65,25, 10, 0.05)))

R
Ruslan., 2021-07-27
@LaRN

Look at the methods of the random module

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question