Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
can you please help me what is the use of keys. "None" and "pass " can you please elaborate with example
thanks in advance
Alexander Davison65,468 Points
None refers to a null value. It's Python's way of saying "nothing." It sounds useless, but it actually can be useful in some case, e.g. you might have a set of numbers, but some are still unknown.
pass, on the other hand, represents that there is currently no body of code in a block. If you are simply building out the heading of a bunch of functions, for instance, but you don't want to write any body yet you want the program to still run, you could use
# Intention: to create an empty function # Confuses Python; causes an error def my_empty_function(): # Python now understands that the body is empty def my_empty_function(): pass
pass isn't used very often, and you almost never see it in completed code (it is mainly used in testing), but occasionally you see code with it so it still is good to know.
thank you very much Alexander Davison