Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>No, there is no such command. It is known as a <a href="http://en.wikipedia.org/wiki/Goto" rel="nofollow"><code>goto</code></a> and pretty much only occured in very early programming language. It is <a href="http://en.wikipedia.org/wiki/Structured_program_theorem" rel="nofollow">never necessary</a>: you can always achieve the same effect with a combination of <code>if</code> and <code>while</code> (or, more Pythonically, <code>for</code>), and <a href="http://www.cs.utexas.edu/users/EWD/ewd02xx/EWD215.PDF" rel="nofollow">considered harmful</a> by many.</p> <p>The reason it is oft abused is that it makes the flow of the program difficult to follow. When reading a normal (structured) program it is easy to tell where control will flow: either around a while loop, into a method call, or split by a conditional. When reading a program using <code>goto</code>, though, the control can jump arbitrarily around the program.</p> <p>In your case, you could either enclose all the intermediate lines inside a conditional, or else refactor the second line into a separate function:</p> <pre><code>def thank(x, name): if [x] in database1: print 'Thank you, {0}:\n'.format(name) </code></pre> <p>(P.S. Are you sure you mean <code>[x] in database1</code> and not <code>x in database1</code>?)</p> <hr> <p>EDIT: Here's an edited version of the code you put into <a href="http://pastebin.com/MY55yBbE" rel="nofollow">your pastebin</a>:</p> <pre><code>print 'Enter your name and surname:' # `.title()` makes first letter capital and rest lowercase name = raw_input('Name: ').title() surname = raw_input('Surname: ').title() # use `.format(...)` to create fancy strings print '{name} {surname}, the Great!'.format(name=name, surname=surname) noes = ['no', 'n'] yesses = ['yes', 'y'] print 'Did you like this?' # `.lower()` for lowercase if raw_input('Yes/No: ').lower() in noes: print 'Did you really mean that?' if raw_input('Yes/No : ') in yesses: print 'So you\'ll be dead, {name}!'.format(name=name) else: print 'Oh, OK, then you\'re free to go, {name}.'.format(name=name) else: print 'Thank you, {name}.'.format(name=name) print 'Try "no" next time!' </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload