Post

PythonPython

A
Anusha V

Posted on 28th March 2024|9 views

0
votes

Xor Python

Can I perform XOR operation on lists in python?

Answers
P
Harshel Mike

Posted on 28th March 2024

Yes, you can perform it easily by using reduce() + lambda + “^” operator look at this example to understand.

ex_list = [5, 4, 2, 8, 3, 9]

  print("The actual list is : " + str(ex_list))

res = reduce(lambda a,b : a^b, ex_list) 

print("The Bitwise XOR of list are : " + str(res))

 

Write your answer

STILL GOT QUERIES?

Get a Live FREE Demo
  • Explore the trending and niche courses and learning maps
  • Learn about tuition fee, payment plans, and scholarships
  • Get access to webinars and self-paced learning videos