#initialize cureent-price to zero
current_price = 0.0
print("First loop current_price is "+str(current_price))
#set previous price to current_price
previous_price = current_price
print('First loop previous_price is '+str(previous_price))
#A method to update the current price through a user input
def getBitMexPrice():
current_price = int(input("Enter current price: "))
return current_price
#Now we update the current price by calling the above method
current_price=getBitMexPrice()
#if previous price is equal to zero, set it to current_price
if previous_price == 0.0:
previous_price = current_price
#print the current_price
print("Current price set to "+str(current_price))
#print the previous price
print("Previous price updated to "+str(previous_price))
Comments
Leave a comment