Jump to content

Is there a way to skip to target line in Python?

Redturtle098
Go to solution Solved by SCHISCHKA,
4 minutes ago, Nfan said:

It is not clear what are You trying yo avhieve, buy maybe like this :

 

if a != 1:

    code to skip

he's trying to do something like a goto command. These are not available in python and you need to put the code in a function.

Hey there,

Is it possible to skip to a target line?

 

 

For example:

 

if a = 1:

    {SKIP TO LINE #}

 

 

I don't really know that much, so any help on achieving this would be appreciated!! :D

Regards,

Redturtle

Link to comment
Share on other sites

Link to post
Share on other sites

It is not clear what are You trying yo avhieve, buy maybe like this :

 

if a != 1:

    code to skip

Link to comment
Share on other sites

Link to post
Share on other sites

4 minutes ago, Nfan said:

It is not clear what are You trying yo avhieve, buy maybe like this :

 

if a != 1:

    code to skip

he's trying to do something like a goto command. These are not available in python and you need to put the code in a function.

             ☼

ψ ︿_____︿_ψ_   

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, SCHISCHKA said:

he's trying to do something like a goto command. These are not available in python and you need to put the code in a function.

Oh i see, it's unfortunate that they don't create something to fix this....  :dry:

 

Thanks for your help! :D

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

2 hours ago, Redturtle098 said:

Oh i see, it's unfortunate that they don't create something to fix this....  :dry:

 

Thanks for your help! :D

 

 

Actually, it's already "fixed". It's considred to be bad to use goto in Your code. There is big paragraph on wiki about it and of course here https://www.explainxkcd.com/wiki/index.php/292:_goto . Try to avoid it :3

Link to comment
Share on other sites

Link to post
Share on other sites

20 minutes ago, Nfan said:

Actually, it's already "fixed". It's considred to be bad to use goto in Your code. There is big paragraph on wiki about it and of course here https://www.explainxkcd.com/wiki/index.php/292:_goto . Try to avoid it :3

 

goto is not in python.

 

3 hours ago, Redturtle098 said:

Hey there,

Is it possible to skip to a target line?

 

 

For example:

 

if a = 1:

    {SKIP TO LINE #}

 

 

I don't really know that much, so any help on achieving this would be appreciated!! :D

Regards,

Redturtle

 

If you're not reusing the code then just put it inside the if else you make a function

def myFunction():
	#code
a=1
if a == 1:
	myFunction()

 

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×