-
Notifications
You must be signed in to change notification settings - Fork 47
/
test3.py
73 lines (61 loc) · 1.3 KB
/
test3.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
62
63
64
65
66
67
68
69
70
71
72
73
def swap_case(s):
result = ""
for i in range(len(s)):
if s[i].isupper():
result += s[i].lower()
else:
result += s[i].upper()
return result
t = "Www.HackerRank.com"
swap_case(t)
def count_substring(string, sub_string):
substring_length = len(sub_string)
string_length = len(string)
end = string_length - 2
cnt = 0
for i in range(0, end):
if string[i:i+substring_length] == sub_string:
cnt += 1
return cnt
s = "ABCDCDC"
sub = "CDC"
count_substring(s, sub)
def string_type(s):
temp = []
for char in s:
temp.append(char.isalpha())
if True in temp:
print(True)
else:
print(False)
temp =[]
for char in s:
temp.append(char.isalpha())
if True in temp:
print(True)
else:
print(False)
temp =[]
for char in s:
temp.append(char.isdigit())
if True in temp:
print(True)
else:
print(False)
temp =[]
for char in s:
temp.append(char.islower())
if True in temp:
print(True)
else:
print(False)
temp =[]
for char in s:
temp.append(char.isupper())
if True in temp:
print(True)
else:
print(False)
temp =[]
z = "qA2"
string_type(z)