Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to remove "None" from output of function related question

    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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading