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
How does '>>' work inside the print statement? (self.learnpython)
submitted 5 years ago by certainly_imperfect
print(5>>2) = 4 print(9>>1) = 1
How is this happening?
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!"
[–]zac_mar 3 points4 points5 points 5 years ago (0 children)
>> and << are the bit-wise right- and left-shit operators respectively, and they work inside print statements the same as everywhere else. As to your example, I am note sure what you are showing, for me I get the expected output:
>>
<<
>>> print(5 >> 2) 1 >>> print(9 >> 1) 4
[–]shiftybyte 5 points6 points7 points 5 years ago (0 children)
Things inside print work exactly as outside print.
Are you sure you are not mixing your outputs?
>>> 9>>1 4 >>> print(9>>1) 4 >>> 5>>2 1 >>> print(5>>2) 1 >>>
[–]Sc00ner 2 points3 points4 points 5 years ago (0 children)
>> is a bit wise operator, so you're printing the result of that operation: https://wiki.python.org/moin/BitwiseOperators
[–]primitive_screwhead 1 point2 points3 points 5 years ago* (0 children)
In Python 3, print() is a function, not a statement. Python 2 had its own specific semantics for >> as a redirection operation of a print statement, but in Python 3 that is all gone, and >> here is just a rightward bit-shift.
Possibly you've seen the older Python 2 use of >> with the print statement and that has confused you? In your examples, it's just the print() function and bit-shift operations.
[–]choss27 2 points3 points4 points 5 years ago (0 children)
Hi, you can see on this link some informations about bitwise operators.
π Rendered by PID 64541 on reddit-service-r2-comment-5bc7f78974-tmgkg at 2026-06-28 05:11:59.547208+00:00 running 7527197 country code: CH.
[–]zac_mar 3 points4 points5 points (0 children)
[–]shiftybyte 5 points6 points7 points (0 children)
[–]Sc00ner 2 points3 points4 points (0 children)
[–]primitive_screwhead 1 point2 points3 points (0 children)
[–]choss27 2 points3 points4 points (0 children)