Aug-13-2021, 03:35 PM
(This post was last modified: Aug-13-2021, 03:37 PM by deanhystad.)
range() is a generator. i is a variable that you are using to reference the value returned by the generator. The generator doesn't know anything at all about i, and changing i has no effect on the generator. You don't even need i for the generator to work.
A while loop does a comparison, so changing the index value does have ah effect. This should work.
for _ in range(5): # Look Ma, no index! print('Hello')This prints 'Hello' five times.
A while loop does a comparison, so changing the index value does have ah effect. This should work.
i = 0 while i < number_of_qubit-2: print(i,i+1) i=i+3 print(i,i+1) i=i-1