79572567

Date: 2025-04-14 07:31:27
Score: 0.5
Natty:
Report link

There is no build-in function like std::swap in C++.

However, this code can perform the task:

def my_swap(obj1, obj2):
    obj1[:], obj2[:] = obj2[:], obj1[:]
l1 = [1, 2, 3]
l2 = [4, 5, 6]
my_swap(l1, l2)
print("l1:", l1)
print("l2:", l2)

Output:

l1: [4, 5, 6]
l2: [1, 2, 3]
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Subir Chowdhury