I know there are a lot of similar questions but my use-case is unique. The following is my list ['apple,mango,fig']. What I want is to split the single element into multiple list elements based on ",". My final list should be like this ['apple','mango','fig']. As far as I know we can convert it into sub-list using split() method. But can I convert it into different elements of the same list? Is this possible?
            Asked
            
        
        
            Active
            
        
            Viewed 538 times
        
    -1
            
            
        - 
                    1Yes, you can use `split()` here as well. If you had tried, you wouldn't want to ask a question. – Austin Feb 25 '20 at 07:08
- 
                    Use ```split()``` for splitting list.\n **Please do try first, and share the code where you are facing problem, Just asking solution will not help.** – Shivam Seth Feb 25 '20 at 07:12
1 Answers
1
            If there is only one element in the list:
print(l[0].split(','))
If there are multiple elements in the list, use:
print([x for i in l for x in i.split(',')])
 
    
    
        U13-Forward
        
- 69,221
- 14
- 89
- 114
 
    