0
How i code in python by using [if statement]
I donot get code by using [if statement]
16 Answers
+ 1
Devender singh
Try do it :
n = int(input(" "))
if n == 10:
print ("2")
else:
print ("1")
The motive of is printing the else is why we dont putted the int,and he confused thinked of it was a sting
Happy coding 🤗🇧🇷
+ 5
Devender singh in your code--
example :
n = input(" ")
if n == 10:
print ("hi")
else:
print ("Hello")
the if condition will be true and executed when and only when you will put n=10, except n=10 no value of n will make the if condition true. So for different value of n else condition will be executed and you will get" Hello" as an output.
Hope things will be clear now👍👍
+ 1
N = input (" ")
if N == 1:
print ("Its equal 1")
else:
print ("2,3,4,5,6...")
+ 1
🇨 🇦 🇹 🦊 i enter your code
n = input(" ")
if n == 10:
print ("hi")
else:
print ("Hello")
When i enter input less than 10 or greater than so it show hello output
But when i enter 10 then it also show hello but why
+ 1
I will share my code
https://code.sololearn.com/cJD54sC82lPJ/?ref=app
+ 1
When n = 10
output show hi but it not show it show hello
+ 1
Just make sure you put a collon (:) at the end of the statement also keep an eye on indentation.
0
Please explain in detail
0
My code want idented block i do not know what mistake i do in code please give me correct of it
https://code.sololearn.com/cr4jnePssMDA/?ref=app
0
Devender singh
You have to tab the print in if
the else have to be togheter with if
example :
n = input(" ")
if n == 10:
print ("hi")
else:
print ("Hello")
0
Devender singh show your code
and if you dont understad the if statemente see him again in the lessons
0
Devender singh
the motive of the output is hello is :
the if is saying N is EQUAL of 10,if he be greater or less,will print the else's print
0
👍
0
🦊 Cᴀᴛ ᴄᴜᴛᴇ
See my under code is it right it give only one output:
https://code.sololearn.com/cUIexbYdj3yi/?ref=app