Write Python3 code to demonstrate convert list of strings to list of tuples Using map() + split() + tuple()


Topic: Write Python3 code to demonstrate convert list of strings to list of tuples Using map() + split() + tuple()

Solution

test_list = ['4, 1', '3, 2', '5, 3'] 
print("The original list : " + str(test_list)) 
res = [tuple(map(int, sub.split(', '))) for sub in test_list] 
print("The list after conversion to tuple list : " + str(res)) 



List all Python Programs