Browse Source

cleanup

master
Gharke 2 months ago
parent
commit
8af2700377
  1. 16
      2-basics/blockchain.py

16
2-basics/blockchain.py

@ -1,13 +1,25 @@
blockchain = []
def get_last_blockchain_value():
""" Returns the last value of the current blockchain. """
return blockchain[-1]
def add_value(transaction_amount, last_transaction=[1]):
""" Append a new value as well as the last blockchain value
Arguments:
:transaction_amount: The amount that should be added.
:last_transaction: The last blockchain transaction (default[1])
"""
blockchain.append([last_transaction, transaction_amount])
def get_user_input():
return float(input('Your transaction amount please'))
tx_amount = get_user_input()
add_value(tx_amount)
add_value(5.3)
add_value(2.8, get_last_blockchain_value())
tx_amount = get_user_input()
add_value(tx_amount, get_last_blockchain_value())
print(blockchain)
Loading…
Cancel
Save