- 2
If else
If is false we write code or not
2 ответов
+ 2
Depends on you.
x = 1 + 1
if x == 1:
print("1")
>>> No output.
- - - - - - - - - - - - - - - -
y = 1 + 1
if y == 1:
print("1")
else:
print("Others")
>>> Others
+ 1
Shaik Shabeera Begum Doesn't matter. We should write because everytime you can't get false.
Example:
int a = 10;
int b = 20;
if (a > b) here a > b returns false but it's not necessary that everytime a will be greater than b.