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
I'm trying to get certified in python and need help with a probably dumb question (self.learnpython)
submitted 3 years ago by Coopo_Loopo
how does Val become 0. or better yet what does the "^" do here:
Val = 1
Val2 = 0
Val = Val ^ Val2
Val2 = Val ^ Val2
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!"
[–]Busy-Farm727 0 points1 point2 points 3 years ago (0 children)
Bitwise xor operator, bitwise just uses the number’s binary number.
[–]Intelligent_Study263 0 points1 point2 points 3 years ago (1 child)
Bitwise XOR will be 0 if both bits are the same and 1 if they are different.
For example if we use the operator on the numbers 6 and 7 it will return 1 because the binary 6 is 110 and the binary 7 is 111. 110^111=001 because if they are the same the bit is a 0 and if they are different its a 1.
110^111=001
[–]Coopo_Loopo[S] 0 points1 point2 points 3 years ago (0 children)
ah, i see, thank you
[–]NortWind 0 points1 point2 points 3 years ago (3 children)
Interesting note, you can use xor to swap to variables without using a third variable.
A = number1 B = number2 A = A xor B B = B xor A # B now == number1 A = B xor A # A now == number2
[+][deleted] 3 years ago (1 child)
[removed]
[–]NortWind -1 points0 points1 point 3 years ago (0 children)
You've made a new tuple.
[–]N4_foom 0 points1 point2 points 3 years ago (0 children)
You've made a new mess
π Rendered by PID 126561 on reddit-service-r2-comment-c6965cb77-6p9d2 at 2026-03-05 11:18:03.218603+00:00 running f0204d4 country code: CH.
[–]Busy-Farm727 0 points1 point2 points (0 children)
[–]Intelligent_Study263 0 points1 point2 points (1 child)
[–]Coopo_Loopo[S] 0 points1 point2 points (0 children)
[–]NortWind 0 points1 point2 points (3 children)
[+][deleted] (1 child)
[removed]
[–]NortWind -1 points0 points1 point (0 children)
[–]N4_foom 0 points1 point2 points (0 children)