get stock data in python

import yfinance as yf
import matplotlib.pyplot as plt
# Get the data for the stock Apple by specifying the stock ticker, start date, and end date
data ='AAPL','2016-01-01','2018-01-01') 
# Plot the close prices

Here is what the above code is Doing:
1. We’re using the yfinance package to download the data for the stock Apple.
2. We’re specifying the start date and end date as ‘2016-01-01’ and ‘2018-01-01’.
3. We’re using the plot() method to plot the close prices.
4. We’re using the show() method to display the plot.

The output of the code should look like this:

As you can see, the plot shows the close prices for the stock Apple for the specified time period.