0

How i code in python by using [if statement]

I donot get code by using [if statement]

5th May 2021, 4:53 PM
Devender Singh Rajpurohit
16 ответов
+ 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 🤗🇧🇷
6th May 2021, 4:49 PM
Katdotbrush
Katdotbrush - avatar
+ 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👍👍
7th May 2021, 11:59 AM
คгשเภ๔ кย๓คг
คгשเภ๔ кย๓คг - avatar
+ 1
N = input (" ") if N == 1: print ("Its equal 1") else: print ("2,3,4,5,6...")
5th May 2021, 11:30 PM
Katdotbrush
Katdotbrush - avatar
+ 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
6th May 2021, 4:30 PM
Devender Singh Rajpurohit
6th May 2021, 4:41 PM
Devender Singh Rajpurohit
+ 1
When n = 10 output show hi but it not show it show hello
6th May 2021, 4:42 PM
Devender Singh Rajpurohit
+ 1
Just make sure you put a collon (:) at the end of the statement also keep an eye on indentation.
7th May 2021, 1:47 PM
Pratibha Bharti
Pratibha Bharti - avatar
0
Please explain in detail
6th May 2021, 4:55 AM
Devender Singh Rajpurohit
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
6th May 2021, 5:05 AM
Devender Singh Rajpurohit
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")
6th May 2021, 1:27 PM
Katdotbrush
Katdotbrush - avatar
0
Devender singh show your code and if you dont understad the if statemente see him again in the lessons
6th May 2021, 4:36 PM
Katdotbrush
Katdotbrush - avatar
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
6th May 2021, 4:39 PM
Katdotbrush
Katdotbrush - avatar
0
👍
7th May 2021, 10:09 AM
Devender Singh Rajpurohit
0
🦊 Cᴀᴛ ᴄᴜᴛᴇ  See my under code is it right it give only one output: https://code.sololearn.com/cUIexbYdj3yi/?ref=app
7th May 2021, 10:36 AM
Devender Singh Rajpurohit