-1

In a file (for simplicity, I will refer to it as stocks.py) I have this function included:

def symbol_input(userinput):
    if userinput.isupper():
        symbol = (df[df['Symbol'] == userinput])
        return symbol

which takes a stock ticker input (ex. AAPL) and outputs this:

      Company Symbol    Weight   Price   Chg     % Chg
0  Apple Inc.   AAPL  6.888732  177.65 -1.73  (-0.96%)

I'm pretty new to Python, but I basically want to call this function from an input in another file, portfolio.py which has stocks.py included. In short, how do I take the input from portfolio.py to make it go to the function above?

Bogs
  • 49
  • 5

1 Answers1

-1

in portfolio.py

import stocks

stock_data = stocks.symbol_input(someinput)

This is a very common thing to do. Quick tutorial

Also as others have pointed out, this a duplicate of

Anu
  • 296
  • 1
  • 11