469,332 Members | 6,678 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,332 developers. It's quick & easy.

How to find whether the list or dictionary is empty?

440 256MB
Hi,

How to find whether the list or dictionary is empty?.

Thanks
PSB
Mar 19 '07 #1
2 9851
bvdet
2,851 Expert Mod 2GB
Hi,

How to find whether the list or dictionary is empty?.

Thanks
PSB
len()
Since this post is too short, I have to add some text to it: "Python Essential Reference", 3rd Edition
Mar 19 '07 #2
bartonc
6,596 Expert 4TB
Hi,

How to find whether the list or dictionary is empty?.

Thanks
PSB
The interactive interpreter is there so that you may try things quickly:
Expand|Select|Wrap|Line Numbers
  1. >>> d = {}
  2. >>> if d:
  3. ...     print "d has entries"
  4. ...     
  5. >>> if not d:
  6. ...     print "empty"
  7. ...     
  8. empty
  9. >>> l = []
  10. >>> if not l:
  11. ...     print "empty list"
  12. ...     
  13. empty list
  14. >>> 
Mar 19 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Dave Opstad | last post: by
6 posts views Thread by rh0dium | last post: by
10 posts views Thread by Ben | last post: by
5 posts views Thread by Bill Jackson | last post: by
3 posts views Thread by bruce | last post: by
4 posts views Thread by dineshv | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Marylou17 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.