Python 17

Python 100 [Python 100] Python 100

while for , '\n'

Python2.x - while

#!/usr/bin/python # -*- coding: UTF-8 -*- import string s = raw_input(':\n') letters = 0 space = 0 digit = 0 others = 0 i=0 while i < len(s): c = s[i] i += 1 if c.isalpha(): letters += 1 elif c.isspace(): space += 1 elif c.isdigit(): digit += 1 else: others += 1 print 'char = %d,space = %d,digit = %d,others = %d' % (letters,space,digit,others)

Python3.x - for

#!/usr/bin/python3 import string s = input(':\n') letters = 0 space = 0 digit = 0 others = 0 for c in s: if c.isalpha(): letters += 1 elif c.isspace(): space += 1 elif c.isdigit(): digit += 1 else: others += 1 print ('char = %d,space = %d,digit = %d,others = %d' % (letters,space,digit,others))

:
123runoobc  kdf235*(dfl
char = 13,space = 2,digit = 6,others = 2

Python 100 [Python 100] Python 100