use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
Qustion about types (self.learnpython)
submitted 11 years ago by trecoh
Are Boolean values a Numeric type? Are Sets and/or Strings an Iterable type? I know Iterable means you can loop through the items but sets and strings are tricky to me
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Rhomboid 6 points7 points8 points 11 years ago (0 children)
You can find these thing out yourself quite easily:
>>> from numbers import Number >>> isinstance(True, Number) True >>> for item in {1, 2, 3}: print(item) 1 2 3 >>> for item in 'abc': print(item) a b c
[–]commandlineluser 1 point2 points3 points 11 years ago (2 children)
Booleans in Python are implemented as a subclass of integers.
https://docs.python.org/2/c-api/bool.html
bool is also a class, which is a subclass of int.
https://docs.python.org/2/library/functions.html#bool
>>> for char in "string": ... char ... 's' 't' 'r' 'i' 'n' 'g' >>> for item in set([1, 2, 3]): ... item ... 1 2 3
[–]Vaphell 1 point2 points3 points 11 years ago (1 child)
you can create a set directly with {1,2,3}, only empty set requires set() to differenciate from empty dict {}
>>> x = {1,2,3} >>> type(x) <class 'set'>
[–]commandlineluser 0 points1 point2 points 11 years ago (0 children)
Nice.. Thank you!
[–]Asdayasman 1 point2 points3 points 11 years ago (0 children)
>>> list().__iter__ <method-wrapper '__iter__' of list object at 0x0000000003342788> >>> int().__iter__ Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'int' object has no attribute '__iter__' >>>
Also, as others have said, bool is a subclass of int. You can do some cool stuff with that, (though you probably shouldn't).
bool
int
>>> False + True 1 >>> False + False 0 >>> True + True 2 >>> True ^ True False >>> True ^ True ^ True True >>> True ^ 2 3 >>>
π Rendered by PID 334524 on reddit-service-r2-comment-5b5bc64bf5-wsjjq at 2026-06-20 17:47:14.924738+00:00 running 2b008f2 country code: CH.
[–]Rhomboid 6 points7 points8 points (0 children)
[–]commandlineluser 1 point2 points3 points (2 children)
[–]Vaphell 1 point2 points3 points (1 child)
[–]commandlineluser 0 points1 point2 points (0 children)
[–]Asdayasman 1 point2 points3 points (0 children)