Sorry if this has been answered in another way or place, I just couldn't figure it out. SO I am playing around with python for the first time and was just trying to create a very simple basic blockchain model where I can add values to the chain but as I am adding values I show the total available "funds" within the list.
Here is what I have so far:
import numpy as np
name = raw_input("please enter your name: ")
# For some reason I have to use the raw_input here or get an error message
original_money = float(input("how much money do you have? "))
# Requesting user to input their original available "funds" amount
print("Hi " + name + " you have $" + str(original_money))
print("in order to make purchases, you need to add money to your wallet")
wallet = [original_money]
def get_last_wallet_value():
return wallet [-1]
def add_value(last_added_value, existing_value=[original_money]):
wallet.append([existing_value, last_added_value])
# I am lost here, no idea what to do to add the whole value of available "funds" within the list as they are getting added to the list
def sum_wallet_content():
return np.sum(wallet)
tx_value = float(input("please enter how much you would like to add: "))
add_value(tx_value)
print(name + " you now have $" + str(tx_value+original_money) + " in your acount!")
# Here is where my problem starts since it is calling the sum_wallet_content and I am having troubles setting that up
tx_value = float(input("please enter how much you would like to add: "))
add_value(tx_value, get_last_wallet_value())
print(name + " you now have $" + sum_wallet_content() + " in your account!")
tx_value = float(input("please enter how much you would like to add: "))
add_value(tx_value, get_last_wallet_value())
tx_value = float(input("please enter how much you would like to add: "))
add_value(tx_value, get_last_wallet_value())
tx_value = float(input("please enter how much you would like to add: "))
add_value(tx_value, get_last_wallet_value())
print(wallet)
Basically, think of this is a simple wallet where you will get your available funds within your wallet each time you add money to it. It will also keep track of each time money was added or deducted. As mentioned on top, a very basic blockchain.
I would greatly appreciate any advice on this.