fork download
  1. # your code goes here
  2.  
  3. def sample(s):
  4. for i, c in enumerate(s):
  5. if i % 2 == 1 and c.isupper():
  6. return True
  7. return False
  8.  
  9.  
  10. def advanced_stat(strings, func=sample):
  11. res = []
  12. for s in strings:
  13. if not func(s):
  14. res.append(s[0:5])
  15. return res
  16.  
  17.  
  18. s = "Mama mIla RamU ddD Eeee fffff ggggggg hhhhhhhhhhhhh"
  19. print(advanced_stat(s.split()))
  20.  
Success #stdin #stdout 0s 23296KB
stdin
Standard input is empty
stdout
['Mama', 'ddD', 'Eeee', 'fffff', 'ggggg', 'hhhhh']