The number of consecutive digits of the string of user input statistics

Bai watched the video, which is the proper way questions, demand is: the number of consecutive digits entered by the user in a string statistics, alas, had to get this title, the idea is very melancholy, like a lot, and finally made out with sophisticated methods the use of a regular re import library, string matching, but today, through the integration of new ideas, put it another thought were resolved, but fortunately, relatively simple to understand, this special record, to facilitate access to follow-up and to share specific code as follows:

# ! / Usr / bin / Python the env 
# - * - Coding: UTF-. 8 - * - 
# the Author: Mr.Lee 

info = INPUT ( ' Enter only a string of numbers and letters: ' ) .strip ()
 for I in info:
     IF i.isalpha (): 
        info = info.replace (I, "  " ) 
LS = info.split ()
 Print (len (LS))

Guess you like

Origin www.cnblogs.com/m-r-lee/p/12163433.html