+ 6

Can if statement be nested infinitely?

2nd Oct 2019, 4:30 AM
SangMinCNSA
SangMinCNSA - avatar
11 ответов
+ 9
Nothing on a computer can be done infinitely. There is always a memory limit.
2nd Oct 2019, 8:22 AM
Sonic
Sonic - avatar
+ 6
~ swim ~ Is that about strictly nested if statements or could I have more by using functions? For example that I have 200 nested if statement, that has a function call in the innermost if statement, and that function call could have 100 nested if statements? Would it work fine?
2nd Oct 2019, 8:07 AM
Seb TheS
Seb TheS - avatar
+ 3
Yes, but it is not strictly practical to have lot of nested if statements.
2nd Oct 2019, 7:04 AM
Seb TheS
Seb TheS - avatar
+ 3
interesting question by Seb TheS
2nd Oct 2019, 8:08 AM
Brave Tea
Brave Tea - avatar
+ 3
In js, infinite loops crash my phone
2nd Oct 2019, 12:58 PM
Hbeefsandwich
Hbeefsandwich - avatar
+ 3
In Python the limit is given by the max indentation level, which generally is 100. https://code.sololearn.com/cOZam70Q9Yuc/?ref=app Try with this program: if you put NESTED-IFS to 100, you will receive an IndentationError. Instead, 99 is okay.
4th Oct 2019, 4:56 AM
Bilbo Baggins
Bilbo Baggins - avatar
+ 2
Yep
2nd Oct 2019, 5:04 AM
Trigger
Trigger - avatar
+ 2
As long as your memory can handle it
2nd Oct 2019, 5:04 AM
Trigger
Trigger - avatar
+ 2
Yea it can, but you probably shouldn’t or 2 days later you won’t understand a thing from what you wrote...
2nd Oct 2019, 2:23 PM
Kireii
Kireii - avatar
+ 1
it wouldnt be very good practice though
2nd Oct 2019, 7:24 AM
Brave Tea
Brave Tea - avatar
0
Yes it can be but until the memory is there
5th Oct 2019, 8:39 AM
Priya Trikoti
Priya Trikoti - avatar