How to split a list with one string into a list with words in Python

2 Answers

0 votes
def split(lst): 
    return lst[0].split() 
  
lst =  ["python java php c++ c#"] 

lst = split(lst) 
  
print(lst)
  

  
  
'''
run:
  
['python', 'java', 'php', 'c++', 'c#']
  
'''

 



answered Jan 22, 2020 by avibootz
0 votes
def split(lst): 
    return ' '.join(lst).split() 
    
lst =  ["python java php c++ c#"] 

lst = split(lst) 
  
print(lst)
  

  
  
'''
run:
  
['python', 'java', 'php', 'c++', 'c#']
  
'''

 



answered Jan 22, 2020 by avibootz

Related questions

2 answers 244 views
3 answers 286 views
1 answer 205 views
1 answer 108 views
1 answer 178 views
3 answers 289 views
...