Recurrent neural networks (RNNs) and long short-term memory (LSTM) models have demonstrated tremendous effectiveness in modeling time series data due to the ability they possess to capture temporal dependencies. Stock market data is an example of time series data. Stock price data is very volatile and dynamic therefore one of the most turbulent areas to invest in might be the stock market. The choice to buy or sell stocks is heavily influenced by external circumstances and statistical analysis of previous stock performance. Stock price index forecasting has been a major area of research for many years and many machine learning and deep learning methods have been proposed to simplify this hard process, but little success has been discovered so far.In this paper, the application of RNNs and LSTMs on a stock price dataset to predict future values is explored. We start with Recurrent neural networks (RNNs) to predict the values but one of the major challenges with it is the "vanishing gradient" problem, which makes it difficult for the network to learn long-term dependencies in the data. To overcome this long short-term memory (LSTM) was used which eliminates the vanishing gradient problem. Data were normalized and divided into time steps to determine the relationship between past values and future values to make accurate predictions. The outcomes show that the MLS LSTM method significantly outperforms existing algorithms, achieving a prediction accuracy of 98.1% on the training data set and a 91.97% accuracy on the testing data set.