fork download
  1. mystr = "BEGIN here is some text END BEGIN END"
  2. words = mystr.split()
  3.  
  4. k_begin = 0
  5. k_end = 0
  6.  
  7. print("My string was =")
  8. print(mystr)
  9.  
  10. for word in words:
  11. print(f"\nMy word = {word}")
  12. if word == "BEGIN":
  13. k_begin += 1
  14. elif word == "END":
  15. k_end += 1
  16.  
  17. B = (k_begin == k_end)
  18.  
  19. print("B =", B)
  20.  
  21.  
Success #stdin #stdout 0.09s 14136KB
stdin
Standard input is empty
stdout
My string was =
BEGIN here is some text END BEGIN END

My word = BEGIN

My word = here

My word = is

My word = some

My word = text

My word = END

My word = BEGIN

My word = END
B = True