Write Python3 code to demonstrate working of Extract Tuples with all Numeric Strings Using all() + list comprehension + isdigit()


Topic: Write Python3 code to demonstrate working of Extract Tuples with all Numeric Strings Using all() + list comprehension + isdigit()

Solution

test_list = [("45", "86"), ("Gfg", "1"), ("98", "10"), ("Gfg", "Best")] 
print("The original list is : " + str(test_list)) 
res = [sub for sub in test_list if all(ele.isdigit() for ele in sub)] 
print("Filtered Tuples : " + str(res)) 



List all Python Programs