-5

Qiskit error code 'qr' not defined

It should be defined I expect. It may be the difference in the version of software on the video I watched vs my software. I tried 'import qiskit' and it still gave me the error code. I'm not sure but I'm just starting out and it's being real funky. Suggestions are much appreciated!

  • 1
    Did you mean to type `qr = QuantumRegister(2)`? Looks like a typo. – blackbrandt Jun 06 '23 at 13:51
  • use from qiskit import * (https://docs.python.org/3/reference/import.html#package-relative-imports) – Quantum Jun 06 '23 at 14:00
  • Welcome to SO! Please see "[ask]", "[Stack Overflow question checklist](https://meta.stackoverflow.com/questions/260648)" and "[mre]" and all their linked pages, along with [Why not upload images of code on SO when asking a question?](https://meta.stackoverflow.com/a/285557/128421) and [Link rot](https://en.wikipedia.org/wiki/Link_rot). – the Tin Man Jun 10 '23 at 21:22

1 Answers1

0

Usually this is because you have not created a quantum register. You can do this by using the following code.

# Define a quantum register named 'qr' with 1 qubit
qr = QuantumRegister(1)
Noah
  • 1