Search code examples
pythonloopssubtraction

Subtraction in a while loop


How can I subtract 1000 from my max variable so I decrement the value each time it loops?

while 1:
    max = 160000
    players = []
    players.append(Player(202556,32000))
    randomPlayer = random.choice(players)
    time.sleep(random.randint(1,4))
    items = fut.searchAuctions('player',assetId=randomPlayer.assetId,
                               max_buy=randomPlayer.maxBid,max_price=max)
    max-1000
    print max

Solution

  • You need to move max outside of the while loop. Otherwise you will always restart the max with the same value. Then decrease the max value.

    max = 160000 # scope outside loop while 1: max -= 1000 # decrease variable print max