Home > OS >  How to remove "None" from output of function related question
How to remove "None" from output of function related question

Time:10-22

    def function1():
    print("Aww im sorry to hear")
    
def function2():
    print("Thats fantastic")    
    
    
def function3():
    print("Invalid response")    
    

ansr = input(print("Did you have a good day at school? Answer 'Y' or 'N'!!"))

if ansr == "Y":
    function2()
elif ansr == "N":
    function1()
else:
    function3()

Output

    Did you have a good day at school? Answer 'Y' or 'N'!!
None

Is there any reason "none" is being returned?? and if so how would i adjust my code to get rid of it?

CodePudding user response:

Don't print inside input. The prompt message is automatic.

ansr = input("Did you have a good day at school? Answer 'Y' or 'N'!!")

print returns None here a similar example

print(print('Hallo'))

Output

Hallo
None
  • Related