My instance is not updating in my while loop : <p>I want to recalculate the hash by changing the nonce by 1. but the instance of self.hash is not changing. </p>

<p>I am not that experienced and do not know how to fix these types of issues</p>

<pre><code>import hashlib

class Block:

  def __init__(self, timestamp, transaction, previousHash = ''):
    self.timestamp = timestamp
    self.transaction = transaction
    self.nonce = 0
    self.previousHash = previousHash
    self.hash = self.calculateHash()

  def mineBlock(self):
    checkIfTrue = str(self.hash).startswith('0')
    while checkIfTrue != True:
        self.nonce += 1
        self.hash = self.calculateHash()
        print(self.hash)

    print("block mined")

  def calculateHash(self):
    h = hashlib.sha256((str(self.timestamp) + str(self.transaction) + str(self.previousHash) + str(self.nonce)).encode('utf-8'))
    return h.hexdigest()
</code></pre>
