S
S
swyt2021-12-09 20:06:12
Python
swyt, 2021-12-09 20:06:12

How to xor multiple numbers in python?

There are four binary numbers, I need to xor these numbers, how can I do it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Kuts, 2021-12-09
@fox_12

res = 0b1100100 ^ 0b0100111
print(bin(res))
# 0b1000011

for four numbers, I hope you can guess how ...

O
Osmanov Osman, 2021-12-09
@OSMANOF

Let's say there are numbers a, b, c and d.
Then we use the ^ operator between them.
print(bin(a ^ b ^ c ^d))
This operator: ^ is exclusive or.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question