+ 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
11 odpowiedzi
+ 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)
+ 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.
+ 4
You need to call function
+ 4
Atul [Inactive] ,
to call the function we need to write a3(), otherwise the function will not be executet.
+ 3
Lothar yes that's what I told. And I think it could be understood by Subod Hiruna
+ 3
This works easily 🤷🏻♂️
x=int(input("Enter Number"))
y=int(50)
if x>y :
print("yes")
else:
print("no")
+ 3
+ 2
At the bottom you just write a3
+ 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!
+ 2
Because you did not call the function
It should be like a
a3()
0
Call the function