human
Print all triplets with given sum | Prints all triplets in arr [ ] with given sum.
Driver code"
How can the above be solved in Python?
 ... Write me a code to print all triplets with given sum and the other steps required?
assistant
#Here is code to print all triplets with given sum and the other steps required.
 def findTriplets ( arr , n , sum ) :
	for i in range ( 0 , n - 2 ) :
		for j in range ( i + 1 , n - 1 ) :
			for k in range ( j + 1 , n ) :
				if ( arr [ i ] + arr [ j ] + arr [ k ] == sum ) :
					print ( arr [ i ] , " ▁ " , arr [ j ] , " ▁ " , arr [ k ] , sep = " " )
arr = [ 0 , - 1 , 2 , - 3 , 1 ]
n = len ( arr )
findTriplets ( arr , n , - 2 )