fork download
  1. def identifiers(text, IDN):
  2. separators = '.,;:!?()[]\'"–-'
  3. for s in separators:
  4. text = text.replace(s, ' ')
  5. slova = text.split()
  6. for slovo in slova:
  7. if len(slovo) > 0 and slovo[0].upper() in ['I', 'Y', 'K', 'L', 'M', 'N']:
  8. IDN.append(slovo)
  9. text = """Ukraine[a] is a country in Eastern Europe. It is the second-largest country in Europe after Russia, which borders it to the east and northeast.[b] Ukraine also borders Belarus to the north; Poland and Slovakia to the west; Hungary, Romania and Moldova[c] to the southwest; and the Black Sea and the Sea of Azov to the south and southeast.[d] Kyiv is the nation's capital and largest city, followed by Kharkiv, Odesa, and Dnipro. Ukraine's official language is Ukrainian"""
  10. IDN = []
  11. identifiers(text, IDN)
  12. print("Ідентифікатори змінних, які починаються з букв I, Y, K, L, M або N:")
  13. print(IDN)
Success #stdin #stdout 0.13s 14204KB
stdin
Standard input is empty
stdout
Ідентифікатори змінних, які починаються з букв I, Y, K, L, M або N:
['is', 'in', 'It', 'is', 'largest', 'in', 'it', 'northeast', 'north', 'Moldova', 'Kyiv', 'is', 'nation', 'largest', 'Kharkiv', 'language', 'is']