Advertisement
Nenogzar

Untitled

Jan 21st, 2024
933
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.00 KB | None | 0 0
  1. text = input()
  2. counter = 0
  3. convert_text_to_lower = list(text.lower())
  4. i = 1
  5. check_len = len(convert_text_to_lower)
  6. for word in convert_text_to_lower:
  7.     if check_len - 2 == i:
  8.         break
  9.     check_word = word + convert_text_to_lower[i] + convert_text_to_lower[i + 1] + convert_text_to_lower[i + 2]
  10.     i += 1
  11.     if "sand" in check_word:
  12.         counter += 1
  13.  
  14.     if "fish" in check_word:
  15.         counter += 1
  16.  
  17. check_word = ""
  18. i = 1
  19. for word in convert_text_to_lower:
  20.     if check_len - 1 == i:
  21.         break
  22.     check_word = word + convert_text_to_lower[i] + convert_text_to_lower[i + 1]
  23.     i += 1
  24.     if "sun" in check_word:
  25.         counter += 1
  26.  
  27. check_word = ""
  28. i = 1
  29. for word in convert_text_to_lower:
  30.     if check_len - 3 == i:
  31.         break
  32.  
  33.     check_word = word + convert_text_to_lower[i] + convert_text_to_lower[i + 1] + convert_text_to_lower[i + 2] + \
  34.                  convert_text_to_lower[i + 3]
  35.     i += 1
  36.     if "water" in check_word:
  37.         counter += 1
  38.  
  39. print(counter)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement