Advertisement
valerio_mazza

removeAlpha/Digit con for e while

Nov 17th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.85 KB | None | 0 0
  1. def removeAlpha_for(seqch):
  2. # @param seqch: String
  3. # return string
  4.   new_string = ""
  5.   for s in range(len(seqch)):  
  6.     if not seqch[s].isalpha():
  7.       new_string +=seqch[s]
  8.   return new_string
  9.  
  10. def removeDigit_for(seqch):
  11. # @param seqch: String
  12. # return string
  13.   new_string = ""
  14.   for s in range(len(seqch)):  
  15.     if not seqch[s].isalpha():
  16.       new_string += seqch[s]
  17.   return new_string
  18.  
  19. def removeAlpha_while(seqch):
  20. # @param seqch: String
  21. # return string
  22.   s = 0
  23.   new_string = ""
  24.   while s < len(seqch):
  25.     if not seqch[s].isalpha():
  26.       new_string += seqch[s]
  27.     s += 1  
  28.   return new_string  
  29.  
  30. def removeDigit_while(seqch):
  31. # @param seqch: String
  32. # return string
  33.   s = 0
  34.   new_string = ""
  35.   while s < len(seqch):
  36.     if not seqch[s].isdigit():
  37.       new_string += seqch[s]
  38.     s += 1  
  39.   return new_string
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement