0

Please is the indentation wrong wrong cuz I keep getting error in indentation. I nested the second if statement

number = 28 guess = int(input('Enter a number : ')) if guess==number: print('Congrats, you guessed it right!') if guess<number: print('No, Its a bit higher than that!')

28th Aug 2019, 6:00 PM
Onimisi
Onimisi - avatar
5 Antworten
+ 1
okay, good. well just put both if statements on the same indent level and you are golden
28th Aug 2019, 7:20 PM
Brave Tea
Brave Tea - avatar
0
you shouldn’t nest the second if statement. now it will only check whether or not the number is smaller than ‘number’ when it is already the same == so make both if statements same indentation and it will work
28th Aug 2019, 6:03 PM
Brave Tea
Brave Tea - avatar
0
Are there any conditions for nesting if statements? I'm really confused right now. I know a nested if statement wont be executed when the outer if statement is false. I know this, but i was surprised the code didn't request for my input first to confirm whether the first condition will be satisfied or not before moving to the nested one.
28th Aug 2019, 6:22 PM
Onimisi
Onimisi - avatar
0
can you put a link to your code here? by using the plus button to the left. because when I run this code it does ask for an input as it should. perhaps you copied it differently?
28th Aug 2019, 6:42 PM
Brave Tea
Brave Tea - avatar
0
Here is it https://code.sololearn.com/cQ69fXVTXlsb/?ref=app Edit ; It's working fine now
28th Aug 2019, 7:05 PM
Onimisi
Onimisi - avatar