importdatetimeasdatedefcreate_genesis_block():# Manually construct a block with# index zero and arbitrary previous hashreturnBlock(0,date.datetime.now(),"Genesis Block","0")
# Create the blockchain and add the genesis blockblockchain=[create_genesis_block()]previous_block=blockchain[0]# How many blocks should we add to the chain# after the genesis blocknum_of_blocks_to_add=20# Add blocks to the chainforiinrange(0,num_of_blocks_to_add):block_to_add=next_block(previous_block)blockchain.append(block_to_add)previous_block=block_to_add# Tell everyone about it!print"Block #{} has been added to the blockchain!".format(block_to_add.index)print"Hash: {}\n".format(block_to_add.hash)