stupid title i know :)
But anyways, is there a way to "go to" a previous line.
something like this:

  1. something
  2. something
  3. something
  4. if a<b:

          (go to) / (do) third line
    

ty

i can try and give you an example.
i try to count numbers from 1-10. but when I come to number 5 I want it to do something else.
I know I could do this in a milion other ways, but now I can't think of a good example.

i = 0
while i < 10:
    i += 1
    print (i)

    if i == 4:                    # line 6 #
        print ("This number is 4")

    if i == 5:
        i =*2
        check line 6 and continue from there       # this is the part im interested # 

Something like that. Hope that doesn't confuse you even more :)
can you check line 6 with new "i".

Ty again

Mybe you need like that?
i = 0
while i < 10:
    i += 1
    if i == 5:
        #do somthing
        print "Hello World"
        continue
    else:
        i == 6
        print i

">>> ================================ RESTART ================================
>>> 
1
2
3
4
Hello World
6
7
8
9
10
>>> "

Edited 3 Years Ago by tony75

@tony75, what is line 10 going to do?

There is no goto in Python. Design your program properly and you don't need this old Basic Language horror.

Edited 3 Years Ago by vegaseat

ty, I will try using definitions :D
Why exaclly is this horror?
Im trying to understand this as well as I can.

Python does have a goto add on Click Here but it was an April Fool's joke so I don't know if it works or not (and don't care as I will not be using it).

I wasn't joking.
I guess this doestn matter because there are other better ways to do it.
I just thaught I could do something in this way but definitions are actually very good :D

This question has already been answered. Start a new discussion instead.