-1
if condition: #this statement
    print("if execution") #if statements
else:
    print("if execution")

if condition check first time and then it's statements executed. Then again it check if condition second time.

In general it's not possible as on the basis of if condition either if statements or else statements executes. As if condition is checked once only.

I can do this in C++ with label and goto.

#include <iostream>
using namespace std; 
int main() {
    int cond = 1;

    // if with label l1
    l1: if(cond) { // ...to here
        cout << "inside if";
        cond = 0;
        goto l1; //this switching statement control...
    }

    //else
    else {
        cout << "\ninside else";
    }
    return 0;
}

Check this: Check c++ example

Some people in comment section are confusing switch with 'switch' keyword in programming language.

{switch please! not switch keyword}

switch statement controls mean moving control of one statement to another statement.

Deepak Gautam
  • 1,309
  • 12
  • 14

1 Answers1

0

I think you are talking about the elif statement. Have a look here

if condition1:
    print('condition1 True')
elif condition2:
    print('condition1 False, condition2 True')
elif condition3:
    print('condition1 and condition2 are False, condition3 True')
else:
    print('none of the conditions are True')

If that is not answering your question, please update and clarify your original post/question.

Edwin van Mierlo
  • 2,398
  • 1
  • 10
  • 19