fork download
  1. mystring = 'He is a good boy. She was and is a good girl'
  2. newstring = mystring.split()
  3. is_count = 0
  4. was_count = 0
  5. for i in newstring:
  6. if i == 'is' or i == 'Is':
  7. is_count += 1
  8. if i == 'was' or i == 'Was':
  9. was_count += 1
  10. print(is_count)
  11. print(was_count)
Success #stdin #stdout 0.13s 14052KB
stdin
Standard input is empty
stdout
2
1