zyulfi

Number_of_sentences

May 29th, 2025 (edited)
474
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | Source Code | 0 0
  1. # Задача 3
  2. # Имате някакъв текст. Пребройте броя на изреченията в текста и изведете резултата на екрана.
  3.  
  4. text = input("Please enter text: ")
  5. counter = 0
  6.  
  7. for letter in text:
  8.     if ord(letter) == 46 or ord(letter) == 63 or ord(letter) == 33: # checking ., ?, !
  9.         counter += 1
  10.  
  11. print(f"The number of sentences in the text is {counter}")
  12.  
  13.  
Advertisement
Add Comment
Please, Sign In to add comment