File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python
2
+ # coding: utf-8
3
+
4
+ # # Return the number of times that the string "hi" appears anywhere in the given string.
5
+ #
6
+ #
7
+
8
+ # In[1]:
9
+
10
+
11
+ def count_hi (str ):
12
+ return str .count ("hi" )
13
+ count_hi ('hihihihi' )
14
+
15
+
16
+ # # Given a string, return a string where for every char in the original, there are two chars.
17
+ #
18
+ #
19
+
20
+ # In[2]:
21
+
22
+
23
+ def double_char (str ):
24
+ new_str = ""
25
+ for char in str :
26
+ new_str += char * 2
27
+ return new_str
28
+ double_char ('Hi-There' )
29
+
30
+
31
+ # # Return True if the string "cat" and "dog" appear the same number of times in the given string.
32
+
33
+ # In[4]:
34
+
35
+
36
+ def cat_dog (str ):
37
+ return str .count ('cat' ) == str .count ('dog' )
38
+
39
+ cat_dog ('1cat1cadodog' )
40
+
41
+
42
+ # In[ ]:
43
+
44
+
45
+
46
+
You can’t perform that action at this time.
0 commit comments