'How can I fix this type of Attribute error?

I am trying to build a blockchain. I am having an attribute error while trying to run the code on the terminal. "Blockchain" object has no attribute "chain".

class Block:
    """""
    Block: A unit of storage
    Stores transactions in a blockchain that supports a cryptocurrency
    """""
    def __init__(self, data):
        self.data = data
        
 
    def __repr__(self):
        return f'Block - data: {self.data}' 
 
 
class Blockchain:
    """""
    Blockchain: A public ledger of transactions.
    Implemented as a list of blocks - data sets of transactions
    """""
    def _init_(self):
        self.chain = []
 
    def add_block(self, data):
        self.chain.append(Block(data))
 
    def __repr__(self):
        return f'Blockchain: {self.chain}'
            
blockchain = Blockchain()
blockchain.add_block( 'one' )
blockchain.add_block( 'two' )
 
 
print(blockchain)

How can I fix this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source