Created
          September 30, 2021 13:46 
        
      - 
      
 - 
        
Save villares/21d395ea7f55d51aded3c4dfa5036066 to your computer and use it in GitHub Desktop.  
    splitting duos
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | names = ['Albert', 'Allison & Peter', 'John & Paul', 'Mary', 'Ann'] | |
| def r_enumerate(iterable): | |
| return reversed(tuple(enumerate(iterable))) | |
| for i, name in r_enumerate(names): | |
| if '&' in name: | |
| a, b = name.split('&') | |
| names[i] = a.strip() | |
| names.insert(i + 1, b.strip()) | |
| print(names) | |
| # result printed: | |
| # ['Albert', 'Allison', 'Peter', 'John', 'Paul', 'Mary', 'Ann'] | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment