Display a digit from keras mnist dataset

# libraries
from keras.datasets import mnist
import matplotlib.pyplot as plt

# for jupyter notebook
%matplotlib inline

# Load mnist data.
(train_images, train_labels), (test_images, test_labels) \
    = mnist.load_data()

# Index of the training image to be displayed
index = 1842

# Display the image
plt.imshow(train_images[index], cmap=plt.cm.binary)
plt.title("Digit: {}".format(train_labels[index]))
plt.show()