+ 1

Why this code isn't work?

def a3(): x=int(input('Enter Number:-')) if (x>50): print ("yes") else: print ("no") https://code.sololearn.com/cggxsW3M9760/?ref=app

24th Aug 2021, 2:21 PM
Subod Hiruna
Subod Hiruna - avatar
11 Antworten
+ 7
Subod Hiruna try this input=int(input('Enter Number:-')) def a3(x): print(x) if (x>50): print ("yes") else: print ("no") a3(input)
24th Aug 2021, 2:35 PM
SAN
SAN - avatar
+ 7
Subod Hiruna , there is no output because you have defined a function a3() , but you never have called it. put a3() as the last line of your code without indentation. this will call your function.
24th Aug 2021, 2:30 PM
Lothar
Lothar - avatar
+ 4
You need to call function
24th Aug 2021, 2:26 PM
Abhay
Abhay - avatar
+ 4
Atul [Inactive] , to call the function we need to write a3(), otherwise the function will not be executet.
24th Aug 2021, 2:55 PM
Lothar
Lothar - avatar
+ 3
Lothar yes that's what I told. And I think it could be understood by Subod Hiruna
24th Aug 2021, 3:34 PM
Atul [Inactive]
+ 3
This works easily 🤷🏻‍♂️ x=int(input("Enter Number")) y=int(50) if x>y : print("yes") else: print("no")
25th Aug 2021, 10:52 AM
Rohan Paul
Rohan Paul - avatar
25th Aug 2021, 2:54 PM
Nirmal Singh
Nirmal Singh - avatar
+ 2
At the bottom you just write a3
24th Aug 2021, 2:29 PM
Atul [Inactive]
+ 2
Subod Hiruna Your code prints nothing as you've not added the extra piece of code to execute the function 'a3'. 'a3' is a variable in Python that stores the reference to the function object in the heap. A pair of parentheses after this reference calls the function. Here's how you can make it work: def a3(): # Uhm, you might as well could deal without the extra variable 'x' x = int(input("Enter the number: ")) if x > 50: print("yes") else: print("no") Here's an even shorter version of your code: def a3(): print("yes" if int(input("Enter: ")) > 50 else "no") # I hope that this answer helps you with your query. Happy coding!
24th Aug 2021, 3:04 PM
Calvin Thomas
Calvin Thomas - avatar
+ 2
Because you did not call the function It should be like a a3()
24th Aug 2021, 10:21 PM
bakeery
0
Call the function
26th Aug 2021, 10:11 AM
Shiva Mahato
Shiva Mahato - avatar