Install package -
pip install yfinance
Write code -
import yfinance as yf
STK = input("Enter share name: ").upper()
data = yf.Ticker (STK).history (period="1d")
last_market_price = data['Close'].iloc[-1]
print(f" Last market price {STK):", last_market_price)
Output :
Enter share name: nvda
Last market price NVDA: 116.06999969482422