Note that torchvision.datasets.MNIST returns a class of type 'torchvision.datasets.mnist.MNIST', not an actual list you an iterate over. You then have to use a dataloader to access the individual data points.
This is the code provided in the example to load MNIST. Can you try this and see?
transform = transforms.Compose([transforms.ToTensor(), transforms.Normalize((0.5,), (0.5,))])

batch_size = 4
trainset = torchvision.datasets.MNIST(root='./data/', train=True, download=False, transform=transform)
trainloader = torch.utils.data.DataLoader(trainset, batch_size=batch_size, shuffle=True, num_workers=2)

testset = torchvision.datasets.MNIST(root='./data/', train=False, download=False, transform=transform)
testloader = torch.utils.data.DataLoader(testset, batch_size=batch_size, shuffle=False, num_workers=2)