# Learning Blockchain through Python: Part 1 **Published by:** [xuanling11](https://paragraph.com/@xuanling11/) **Published on:** 2022-08-19 **URL:** https://paragraph.com/@xuanling11/learning-blockchain-through-python-part-1 ## Content Blockchain is a big word and a confusing word to newbies. A blockchain is an online public bookkeeping ledger.https://www.beginner-bookkeeping.com/bookkeeping-ledgers.html It automatically registers a financial transaction from the sender to the receiver. Before we go into depth about the blockchain, let’s build a simple financial transaction from Python.Here are the thought processes:What information do you need to complete a transaction?You will need: 👉 sender’s name 👉 receiver’s name 👉 amount to transactHow do you store the data with information?In Python, dictionaries are preferable for transaction data storage since it is a set of key: value pairs that are searchable.Construction a transactionIf Alice, the sender, sent $30 to Bob, the receiver, through a transaction, here is how to construct the data:transaction1 = { ‘amount’: ‘30’, ‘sender’: ‘Alice’, ‘receiver’: ‘Bob’} More transactionsYou can register more transactions by repeating the above method:transaction2 = { ‘amount’: ‘200’, ‘sender’: ‘Bob’, ‘receiver’: ‘Alice’} transaction3 = { ‘amount’: ‘300’, ‘sender’: ‘Alice’, ‘receiver’: ‘Bob’ } transaction4 = { ‘amount’: ‘300’, ‘sender’: ‘Bob’, ‘receiver’: ‘Alice’ } transaction5 = { ‘amount’: ‘200’, ‘sender’: ‘Alice’, ‘receiver’: ‘Bob’ } transaction6 = { ‘amount’: ‘400’, ‘sender’: ‘Bob’, ‘receiver’: ‘Alice’ } Combine all transactions togetherAssume you will have six transactions total. You combine them together in one assigned variable, “mempool”:mempool = [transaction1, transaction2, transaction3, transaction4, transaction5, transaction6] Add one more transactionSince there is a new transaction that needs to register in the blockchain, we can add through .append() :my_transaction = { ‘amount’: ‘100’, ‘sender’: ‘Alice’, ‘receiver’: ‘Bob’ }mempool.append(my_transaction) Search transactionsNow, you have got your ledger input through Python manually! You can search transactions whichever you want to. For instance, if you want the first 3 transactions, you can do:block_transactions = mempool[0:3]print(block_transactions) Congratulation! You got your blockchain! Although it does not automatically generate and capture transactions, you get your first blockchain at least! You can have a code below: https://gist.github.com/xuanling11/262023653ccbde9e7151b8c4aab37b1aIf you enjoy reading my articles, buy me a coffee here. Photo byGuerrillaBuzz Crypto PR onUnsplash ## Publication Information - [xuanling11](https://paragraph.com/@xuanling11/): Publication homepage - [All Posts](https://paragraph.com/@xuanling11/): More posts from this publication - [RSS Feed](https://api.paragraph.com/blogs/rss/@xuanling11): Subscribe to updates - [Twitter](https://twitter.com/xuanling11): Follow on Twitter