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.