How can I make this code more Pythonic - specifically, merging something into a function?
Question: I know that this code would look a lot better if I made it so that checking
the current prices against the open prices were in a function so I wouldn't
have to re-write it for every stock I want to check, but I'm not sure how to
get started on doing that properly. Do any of you have some tips to get me
started?

    
    
    from yahoo_finance import Share
    
    apple = Share('AAPL')
    
    appleopen = float(apple.get_open())
    applecurrent = float(apple.get_price())
    
    if appleopen > applecurrent:
        print(("Apple is down for the day. Current price is"), applecurrent)
    else:
        print(("Apple is up for the day! Current price is "), applecurrent)
    
    applechange = (applecurrent - appleopen)
    if applechange > 0:
        print(('The price moved'),abs(applechange),("to the upside today."))
    else:
        print(('The priced moved'),abs(applechange),("to the downside today."))
    print('-----------------------')
    nflx = Share('NFLX')
    
    nflxopen = float(nflx.get_open())
    nflxcurrent = float(nflx.get_price())
    
    if nflxopen > nflxcurrent:
        print(("Netflix is down for the day. Current price is"), nflxcurrent)
    else:
        print(("Netflix is up for the day! Current price is "), nflxcurrent)
    
    nflxchange = (nflxcurrent - nflxopen)
    if nflxchange > 0:
        print(('The price moved'),abs(nflxchange),("to the upside today."))
    else:
        print(('The priced moved'),abs(nflxchange),("to the downside today."))
    


Answer: Try this:

    
    
    from yahoo_finance import Share
    Store = {
        'AAPL': 'Apple',
        'NFLX': 'Netflix'
    }
    for code in Store:
        name, shr = Store[code], Share(code)
        sopen = float( shr.get_open() )
        scurr = float( shr.get_price() )
        schange = scurr - sopen
        movement = 'down' if schange < 0 else 'up'
        print( format("{} is {} for the day. Current price is {}"), name, movement, scurr) )
        print( format('The price moved {} to the {}side today.',abs(schange), movement) )
        print('-----------------------')
    

