Mar-10-2019, 11:12 AM
Hello everyone, I'm new to python and currently stuck on a problem,I want to convert a list containing variable data types to strings while maintaining the original structure of the lists, for e.g.
Any help would be greatly appreciated.
inputlist=['Cities',14,'WACC',(32,'KHI',208.55567),['Stat',14,'RS0']]Should become
outputlist=['Cities','14','WACC',('32','KHI','208.55567'),['Stat','14','RS0']]Map doesn't work as it converts the inner tuples and lists to a complete string breaking the original structure.
outputlist=list(map(str,inputlist))The lists are variable sized with changing internal structures and can be long containing thousands of elements with each element having the possibility of being a tuple or list itself.
Any help would be greatly appreciated.