Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. s="bboobbobobbobbbbobboobnbobobbotbobbw"
  2. b=0
  3. o=0
  4. bob=0
  5. for char in s:
  6.  
  7. if char=="b":
  8. b=1
  9. if char=="o" and b==1:
  10. o+=1
  11. if char=="o" and b==1 and o!=1:
  12. b=0
  13. o=0
  14. if char=="b" and o==1:
  15. bob+=1
  16. b=1
  17. o=0
  18. if char!="b" and char!="o":
  19. b=0
  20. o=0
  21.  
  22.  
  23.  
  24.  
  25. print('Number of times bob occurs is: '+str(bob))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement