my_list = [1,3,6,8,2,7,5,7,9,2,16,4]

def my_oracle(my_input):
    winner = 9
    response = False
    if winner == my_input:
        response = True
    return response

for index, number in enumerate(my_list):
    if (my_oracle(number) == True):
        print("Winner winner chicken dinner! at index = %i"%index)
        print("%i times the Oracle was called"%(index+1))
        break

from qiskit import *
import matplotlib.pyplot as plt
import numpy as np

# create the oracle quantum circuit
oracle = QuantumCircuit(2, name='oracle')
oracle.cz(0,1) # apply the Controlled-Z gate or CZ gate
oracle.to_gate() # make oracle into its own gate
oracle.draw()

backend = Aer.get_backend('statevector_simulator')
grover_circuit = QuantumCircuit(2,2) # 2 qubits, 2 classical registers
grover_circuit.h([0,1]) # apply hadamard gate on both qubits 0 and 1 to prepare superposition state discussed in description.md
grover_circuit.append(oracle, [0,1]) # append oracle to be able to query each state at same time
grover_circuit.draw()

job = execute(grover_circuit, backend)
result = job.result()

sv = result.get_statevector()
np.around(sv, 2)

reflection = QuantumCircuit(2, name='reflection')
reflection.h([0,1]) # apply hadamard gate on all qubits to bring them back to '00' state from the original 's'  state
reflection.z([0,1]) # apply Z gate on both qubits
reflection.cz(0,1) # controlled-z gate
reflection.h([0,1]) # transform back with hadamard on both qubits
reflection.to_gate()

reflection.draw()

backend = Aer.get_backend('qasm_simulator')
grover_circuit = QuantumCircuit(2,2)
grover_circuit.h([0,1])
grover_circuit.append(oracle, [0,1])
grover_circuit.append(reflection, [0,1])
grover_circuit.measure([0,1], [0,1])

grover_circuit.draw()

job = execute(grover_circuit, backend, shots=1)
result = job.result()
result.get_counts()