0

Else statement

if 1 + 1 == 2: if 2 * 2 == 8: print("if") else: print("else") I did not get why is the output "else". I thought there is no output here.

12th Sep 2020, 5:45 AM
Lilit Ghazaryan
Lilit Ghazaryan - avatar
3 Respostas
+ 3
The output will be else because the second if condition is false(2*2==8). As it is 4==8 which is false. So it will execute the else statement after the second if statement.
12th Sep 2020, 5:48 AM
Aman Kumar
Aman Kumar - avatar
+ 2
Delete your previous same question. Don't make duplicates.
12th Sep 2020, 6:27 AM
Aman Kumar
Aman Kumar - avatar
+ 1
Ive made a similar code now in c++ for you to see. If you don't still understand, indicate!! https://code.sololearn.com/cNVOLMIKGb1Q/?ref=app
12th Sep 2020, 8:05 AM
Rawley
Rawley - avatar