program to find Tuples with positive elements in List of tuples

test_list = [(4, 5, 9), (-3, 2, 3), (-3, 5, 6), (4, 6)]

print("The original list is : " + str(test_list))

res = [sub for sub in test_list if all(ele >= 0 for ele in sub)]

print("Positive elements Tuples : " + str(res))


No comments: