PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, September 16, 2022

[FIXED] why returning None in functions python?

 September 16, 2022     function, printing, python, python-3.x     No comments   

Issue

first image I was having problem when I run this code I raise exception in function then why none is printing

sec image And in this case none is not printing.. pls help


Solution

when a python function does not have a return statement it automatically return None.

In the first image, the print(numcheck(5)) pass the assert but the function return None so it printed None but print(numcheck(-5)) did raise the exception.

In the second image print(numcheck(-5)) raise directly the exception so python did not print anything.



Answered By - Ghassen Sultana
Answer Checked By - Robin (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing