+ 2

How do we nest an if without using parentheses?

14th Feb 2018, 2:16 PM
Yash Mohta
Yash Mohta - avatar
6 Answers
+ 3
For what language? And @Jax, that's not a nested if - It's just a regular if statement
14th Feb 2018, 3:04 PM
Zeke Williams
Zeke Williams - avatar
+ 3
# The loop body is determined by indentation, so inner 'if' statement is more indented than outer one: if condition: do something in the loop start a new loop below if condition: new loop body start do some stuff loop body end when indentation removed continuation of the outer loop outer loop end when indentation removed main flow continuation
15th Feb 2018, 4:00 PM
visph
visph - avatar
+ 2
Like this? x = 10 if x == 10: print(‘hello’)
14th Feb 2018, 2:20 PM
Jax
Jax - avatar
+ 2
x = 10 if x > 5: if x < 20: print ("I'm nested!") Is this what you are asking?
15th Feb 2018, 3:57 PM
Zeke Williams
Zeke Williams - avatar
+ 2
@user guru: Language context is Python, curly brackets are not the subject here (appart the fact I believe the asker was confusing by talking about "parenthesis" instead of "curly brackets")...
16th Feb 2018, 3:36 PM
visph
visph - avatar
0
for python
15th Feb 2018, 3:55 PM
Yash Mohta
Yash Mohta - avatar