Gharke
2 months ago
1 changed files with 14 additions and 2 deletions
@ -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…
Reference in new issue