Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. s = input()
  2. cnt = 0
  3. good = False
  4. for i in range(len(s)):
  5.     if ('a' <= s[i] <= 'z' or 'A' <= s[i] <= 'Z' or (i - 1 >= 0 and i + 1 < len(s)
  6.         and s[i] == '-' and ('a' <= s[i - 1] <= 'z' or 'A' <= s[i - 1] <= 'Z')
  7.         and ('a' <= s[i + 1] <= 'z' or 'A' <= s[i + 1]))):
  8.         good = True
  9.         continue
  10.     else:
  11.         if (good):
  12.             cnt += 1
  13.             good = False
  14. if ('a'<= s[-1] <= 'z' or 'A' <= s[-1] <= 'Z'):
  15.     cnt += 1
  16. print(cnt)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement