16 AnswersNew Answer
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 🤗🇧🇷
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👍👍
thisIsPython = True if thisIsPython: print("This is Python")
1. Your indentation is incorrect. 2. The input statement reads a string not a number. N = int(input()) if N > 10: print ("greater than 10") else: print ("False") See how the int() function converts the input to an integer value. It will throw an error if the input cannot be converted. There is no need to place a string inside the input() function unless you want a prompt on screen (doesn't work too well in the code playground) N = int(input("Enter an Integer: ")) If you do not convert the input to an integer the line if N > 10: will fail because N contains a string that you are comparing with an integer. If you do not want to perform the conversion at the time of input use N = input() if int(N) > 10: This will convert N to an integer before the comparison. I can see from your profile that you are taking the Python for Beginners course. If you have not done so already take a look at the Section "Variables" and the lessons "Taking User Input" and "Working with Input". If you have already completed these lessons you may wish to revisit them.
N = input (" ") if N == 1: print ("Its equal 1") else: print ("2,3,4,5,6...")
🇨 🇦 🇹 🦊 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
I will share my code https://code.sololearn.com/cJD54sC82lPJ/?ref=app
When n = 10 output show hi but it not show it show hello
Just make sure you put a collon (:) at the end of the statement also keep an eye on indentation.
Please explain in detail
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
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")
Devender singh show your code and if you dont understad the if statemente see him again in the lessons
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
🦊 Cᴀᴛ ᴄᴜᴛᴇ See my under code is it right it give only one output: https://code.sololearn.com/cUIexbYdj3yi/?ref=app