How to insert words start with capital letters from string into a list in Python

2 Answers

0 votes
import re 
 
s = 'PythonJavaPascal'
 
lst = re.findall('[A-Z][a-z]*', s) 
 
print(lst)
    
    
    
'''
run:
    
['Python', 'Java', 'Pascal']
    
'''

 



answered Jan 14, 2020 by avibootz
edited Jan 14, 2020 by avibootz
0 votes
import wordninja

s = 'PythonJavaPascalC++'

lst = wordninja.split(s)

print(lst)
     
     
     
'''
run:
     
['Python', 'Java', 'Pascal', 'C']
     
'''

 



answered Jan 14, 2020 by avibootz
...