-2

Is there a way to make lines of code continue on a different line of code? example:

    a = raw_input("1 or 2")
if a == "1" :
    a = raw_input("3 or 4")
    if a == "3" :
        *line of code that makes the script progress at line #14*
    if a == "4" :
        *line of code that makes the script progress at line #14*
if a = "2" :
    a = raw_input("5 or 6")
    if a == "5" :
        *line of code that makes the script progress at line #14*
    if a == "6" :
        *line of code that makes the script progress at line #14*
print ("chocolate")
(^line #14^)
  • 1
    Do you have a better example that more closely resembles your real-world use case? This example could be reduced to `if int(a)<7: print('chocolate')`. – Two-Bit Alchemist Mar 26 '14 at 20:33

1 Answers1

-1

The construct you are looking for is a 'goto' statement, and no python has no support for goto statements. See this question: Is there a label/goto in Python? for a number of hacks that can be used to achieve the type of continuation you want in python.

Community
  • 1
  • 1
caskey
  • 12,305
  • 2
  • 26
  • 27
  • 3
    I don't think this is a helpful answer. Obviously `goto` would do _exactly_ this, but _of course_ there are ways to make the code branch and start executing statements somewhere else, otherwise there would be no programming at all. Better I think to try to understand what the OP really wants and answer the actual question lurking rather than dismiss it without any hint that there is a better way. – Two-Bit Alchemist Mar 26 '14 at 20:40