'Getting error when comparing list item int and integer
The line Where I'm getting the error "TypeError: 'int' object is not subscriptable" is marked with a bunch of !!!! in the code I think the same is happening further on in the code aswell.
I tried with empty lists like endCoin = [] and a few other things but I couldn't find anything that worked for me searching so I've posted here
from random import randint
coins = int(input("Enter how many coins you have: "))
buyin = int(input("Enter stake buyin price: "))
winrate = int(input("Enter your winrate: "))
trophyCurrent = int(input("Enter how many trophies you have right now: "))
trophyRequired = int(input("Enter how many trophies you need for ring: "))
trophyMinus = int(input("Enter how many trophies you lose: "))
trophyPlus = int(input("Enter how many trophies you win: "))
gameCount = 0
endCoin = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
endTrophyCurrent = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
endGameCount = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
averageC = 0
averageT = 0
averageG = 0
repeatTimes = 10
# Get the average amount of games it will take to win a trophy and estimate likelihood of losing all coins
for i in range(0, repeatTimes):
endCoin[i] = coins
endTrophyCurrent = trophyCurrent
endGameCount = gameCount
while endCoin[i] >= buyin and endTrophyCurrent[i] <= trophyRequired: #!!!!!!!!!!
gameOutcome = randint(0, 100)
if gameOutcome >= winrate:
endCoin[i] += buyin
endTrophyCurrent[i] += trophyPlus
elif gameOutcome < winrate:
endCoin[i] -= buyin
endTrophyCurrent[i] -= trophyMinus
endGameCount[i] += 1```
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
