#29594: zerojudge為什麼不給我測資啊啊啊


Super487 (Super487)


table = 'abcdefghijklmnopqrstuvwxyz '

 

while True:

  try:

    s = input().lower()

    result = ''

    for i in s:

      if i in table:

        result += i

    l = result.split(' ')

    print(len(l))

  except:

    break

#29601: Re:zerojudge為什麼不給我測資啊啊啊


cges30901 (cges30901)


table = 'abcdefghijklmnopqrstuvwxyz '

 

while True:

  try:

    s = input().lower()

    result = ''

    for i in s:

      if i in table:

        result += i

    l = result.split(' ')

    print(len(l))

  except:

    break


1. 特殊符號也可能把字分隔開來(我的作法是把特殊符號都改成空格)

2. 可能連續多個空格,這時split()會產生空的元素,造成len太多,可以檢查一下,或者是使用re.split()

3. 字串最前面和最後面的空格要去掉