Certificate Challenge: Introduction to PennyLane

Use this topic to ask your questions about the Certificate Challenge: Introduction to PennyLane.

I seem to get an out of bounds error from my code
Running submission…

          Running on public test set

                Test 1 of 2 failed! 🚫
                    Input: [[[[0.62832, 0.3927, 1.0472, 0.7854],[0.7854, 0.31416, 0.62832, 0.5236]],[[0.31416, 0.7854, 0.7854, 0.3927],[0.31416, 0.3927, 0.31416, 0.3927]]],"PauliY", 0.5236]
                    Expected output: [0.68594, 0.31406]
                    Failure message: Runtime Error: Failed to execute run() function: index 2 is out of bounds for axis 0 with size 2.

                Test 2 of 2 failed! 🚫
                    Input: [[[[1.0472, 0.7854, 3.1416, 0.3927],[1.0472, 0.7854, 3.1416, 0.5236]],[[1.0472, 0.7854, 1.5708, 0.3927],[0.7854, 0.7854, 1.5708, 0.7854]]],"PauliX", 0.7854]
                    Expected output: [0.46653, 0.53347]
                    Failure message: Runtime Error: Failed to execute run() function: index 2 is out of bounds for axis 0 with size 2.

          Running on private test set

                One or more private tests failed. Try again! 🚫 

Looks like you are trying to access array[2] where array is of length 2, so only array[0] and array[1] are accessible. I would suggest to copy the problem notebook and running it on an editable ipynb( like colab or jupyter), and try to see which step exactly is throwing the error.

1 Like

Great analysis @sujay3sriv, and welcome to the forum!

@Hanah_Rahman, a good way to start is using Google Colab. Open a new notebook there and run the following at the beginning of your notebook (including the exclamation mark): !pip install pennylane

You can of course keep using the challenge editor, but if you’re having trouble with debugging then using a notebook can help.

Good luck with the challenge!