0
Rare Chance
I want to create a simple program where when i type "roll" it will 70% generate a R text, 20% SR text, and 10% SSR text, much like lootbox system in videogame. Anyone know how to code it? Not using the if numb < 90 print R if possible...
10 Answers
+ 2
Random has a function called choices where it chooses a value from an iterator (like a list) based on preassigned weights. See below
https://code.sololearn.com/cDCpEz2kxYdD/?ref=app
+ 2
Simple version
https://code.sololearn.com/cBBF6oEWCSvV/?ref=app
+ 2
'*' is an unpacking operator. When used before iterators (lists) it will "unpack" them. Really handy operator to keep in mind
+ 2
Here is an example of it
https://code.sololearn.com/chK00T8myKHg/?ref=app
+ 1
Show your attempt?
The random module in python will be able to help youđđŒ
+ 1
Ok thanks for info! I guess i should spend more time studying python
0
My attempt almost same as yours, any other code?
0
What do you mean by other code?
0
Not using those x > z thing, if possible...
0
Yes this is! By the way can you explain why when we print(choices(...)) the output had a [] and '
Then when we write print(*choices(...)) it will show normal text