码迷,mamicode.com
首页 > 其他好文 > 详细

hackerrank---Find a string

时间:2014-05-14 04:13:06      阅读:308      评论:0      收藏:0      [点我收藏+]

标签:style   blog   class   code   c   tar   

题目链接

在字符串a中查找字符串b出现的次数...貌似不可以用a.count()

附上代码:

1 a = raw_input().strip()
2 b = raw_input().strip()
3 cnt = 0;
4 for i in xrange(len(a)):
5     cnt += 1 if a.find(b, i, i+len(b))!= -1 else 0
6 print cnt

 

hackerrank---Find a string,布布扣,bubuko.com

hackerrank---Find a string

标签:style   blog   class   code   c   tar   

原文地址:http://www.cnblogs.com/Stomach-ache/p/3721921.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!