By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,996 Members | 1,343 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,996 IT Pros & Developers. It's quick & easy.

How To Skip In Python (Similar to GOTO in batch)

P: 16
I have This:
user input (user will enter 1,2 or 3)
code1
code2
code3

How do I, depending on the user input, skip from user input to code3 without reading code2. I know in batch i would do this:

if the users input is 3
GOTO code3

but python has no "GOTO"
Aug 1 '09 #1
Share this Question
Share on Google+
3 Replies


Markus
Expert 5K+
P: 6,050
Look into conditional statements - these are used for code-flow - such as if/else if/else and switch. GOTOs are rarely used in modern programming.
Aug 1 '09 #2

P: 16
I defined a function similar to this:
def code3():
code3_here
if user's input is 3
code3()

And that's how I did it. Thanks for replying anyway.
Aug 2 '09 #3

Markus
Expert 5K+
P: 6,050
@ekasII
Uh... you're welcome.
Aug 2 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.