Home > Software design >  How to keep the value of a variable the same even after a while loop (Python)
How to keep the value of a variable the same even after a while loop (Python)

Time:02-06

Basically I'm making a function that allows the value of the player's gold to be the same temporally even when they collect a certain "card"

def immaculateImmunity(playerGold):
  tempGold = playerGold
  i = 5
  while i>1:
  playerGold

So what should I do now as I'm kinda stuck at the moment

CodePudding user response:

Store value in another variable. before using loop after store value again in the previous variable.

 def immaculateImmunity(playerGold):
      tempGold = playerGold
      i = 5
      a=i
      while i>1:
        playerGold
      i=a

CodePudding user response:

Could this anwer your question

def GoldCollection(StarterGold):
    RequestedTime = 2
    LimitAmmount = 5
    while LimitAmmount > StarterGold:
        if GotCard() or ReqestedTime:
            time.sleep(RequestedTime)
            pass
        StarterGold   1
    return StarterGold
  •  Tags:  
  • Related