There are multiple variables that I'm trying call in multiple parts of the code.
- Firstly I need to call stock in num_loop from product_loop
- Next would be productprice from product_loop and num from num_loop in the final line of the code
def product_loop(): 
   product = input ("Enter product name: ")
   if product == 'apple':
       productprice = 3.5
       stock = 134
   elif product == 'banana':
       productprice = 6.82
       stock = 52    
   else:
       print ("Sorry, no such product. Try again.")
       #loops back to the start of product input
       product_loop()
       
def num_loop():
   num = int(input ("Enter number of products ordered: "))
   if num>stock:        #trying to call stock from product_loop
       print ("Sorry, not enough stock. Try again.")
       num_loop()
totalprice=productprice*num       #trying to call productprice from product_loop and num from num_loop
print(totalprice)
Would I need to use the return statement or a class to accomplish this?
*Edit(How would I use a return statement in this situation?)
 
    