qwerty-
qwerty-

Reputation: 59

Calling a function in another function behaviour

I'm trying to understand this behaviour, a simple test here

def hello():
    a="Hi"
    return a

def choice():
    x=int(input("test: "))
    if x == 1:
        hello()

choice()

I expect that if I input 1 it will print Hi, but here is the output;

>>> 
test: 1
>>> 

Nothing. Even there is no error, program just ending. I'm wondering why this Python behaviour?

Upvotes: 0

Views: 23

Answers (1)

Adam Smith
Adam Smith

Reputation: 54163

Because you never tell it to print anywhere. Try this instead if you expect that output:

...
if x == 1:
    print(hello())
...

Upvotes: 1

Related Questions