-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCodingBat7.py
63 lines (51 loc) · 1.07 KB
/
CodingBat7.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
def double_char(str):
phrase = ""
for x in range(len(str)):
phrase += str[x] + str[x]
return phrase
def count_hi(str):
count = 0
for x in range(len(str)-1):
if str[x:x+2] == "hi":
count += 1
return count
def cat_dog(str):
countC = 0
countD = 0
for x in range(len(str) - 2):
if str[x:x + 3] == "cat":
countC += 1
if str[x:x + 3] == "dog":
countD += 1
return countC == countD
def count_code(str):
count = 0
for x in range(len(str) - 3):
if (str[x:x+2] == "co") & (str[x+3] == "e"):
count += 1
return count
def end_other(a, b):
newA = a.lower()
newB = b.lower()
big = newA
small = newB
if(len(b) > len(a)):
big = newB
small = newA
boo = False
start = len(big) - len(small)
end = len(big)
if big[start:] == small:
boo = True
return boo
def xyz_there(str):
boo = False
if str == "xyz":
return True
for x in range(len(str)-2):
if str[x:x+3] == "xyz":
boo = True
if x != 0:
if(str[x-1] == "."):
boo = False
return boo