fork download
  1. def percentage2(data, *boolfuncs):
  2. """Returns how many % of the 'data' returns 'True' for all given boolfuncs.
  3.  
  4. Only uses str.isalpha() characters and ignores all others."""
  5. count = sum(1 for c in data if c.isalpha())
  6. return sum(1 for x in data if all(f(x) for f in boolfuncs)) / count * 100
  7.  
  8. text = "DOFLAMINGO WITH TOUCH SCREEN lorem ipsum"
  9.  
  10. print( percentage2( text, str.isupper, str.isalpha ))
  11. print( percentage2( text, str.islower, str.isalpha ))
  12.  
Success #stdin #stdout 0.02s 6984KB
stdin
Standard input is empty
stdout
0
0