How to convert list of tuple elements with numbers and strings to list of strings Python

2 Answers

0 votes
lst = [(2, 99, "java"), (34, "php", 7), ("python", "c", 89, True)] 
  
lst = [tuple(str(ele) for ele in tpl) for tpl in lst] 
 
print(lst)
  
       
      
'''
run:
 
[('2', '99', 'java'), ('34', 'php', '7'), ('python', 'c', '89', 'True')]
      
'''

 



answered Apr 14, 2020 by avibootz
0 votes
lst = [(2, 99, "java"), (34, "php", 7), ("python", "c", 89, True)] 
  
lst = [tuple(map(str, tpl)) for tpl in lst] 
 
print(lst)
  
       
      
'''
run:
 
[('2', '99', 'java'), ('34', 'php', '7'), ('python', 'c', '89', 'True')]
      
'''

 



answered Apr 14, 2020 by avibootz
...