Imbadatcoding
Coder
I need to make a weighted prediction based on the outcomes of this list however there are some problems im running into
Here's an example of the output of this code:
It shouldn't output {'5','5','5'} i want it to output a weighted choice based on how many times each one is chosen. Any advice?
Code:
from random import choices
import statistics
from time import sleep
threecount = 0
fourcount = 0
fivecount = 0
pthreecount = 0
pfourcount = 0
pfivecount = 0
lst = []
print("What did you obtain?")
for plays in range(5):
listy = ["3", "4", "5"]
x = int(input("3, 4 or 5 star: "))
lst.append(x)
sleep(.5)
print("List of what you obtained:", lst)
sleep(1)
y = str(statistics.mode(lst))
print("The most common star you got was " + y)
sleep(1)
threecounter = lst.count(3)
print("You obtained a 3 star", threecounter, "times")
sleep(1)
fourcounter = lst.count(4)
print("You obtained a 4 star", fourcounter, "times")
sleep(1)
fivecounter = lst.count(5)
print("You obtained a 5 star", fivecounter, "times")
if input == "3":
pthreecount = pthreecount + 1
if input == "4":
pfourcountt = pfourcount + 1
if input == "5":
pfivecount = pfivecount + 1
x = choices(listy, weights=(pthreecount, pfourcount, pfivecount), k=3)
print(x)
Here's an example of the output of this code:
Code:What did you obtain? 3, 4 or 5 star: 3 3, 4 or 5 star: 3 33, 4 or 5 star: 3 33, 4 or 5 star: 3 3, 4 or 5 star: 3 List of what you obtained: [3, 3, 3, 3, 3] The most common star you got was 3 You obtained a 3 star 5 times You obtained a 4 star 0 times You obtained a 5 star 0 times ['5', '5', '5']
It shouldn't output {'5','5','5'} i want it to output a weighted choice based on how many times each one is chosen. Any advice?