forked from ghanteyyy/nppy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpattern_12.py
52 lines (37 loc) · 1.17 KB
/
pattern_12.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
class Pattern_Twelve:
'''Pattern twelve
U
D U
N D U
A N D U
M A N D U
H M A N D U
T H M A N D U
A T H M A N D U
K A T H M A N D U
'''
def __init__(self, strings='KATHMANDU'):
if isinstance(strings, str):
self.strings = strings
else: # If provided 'strings' is integer then converting it to string
self.strings = str(strings)
self.length = len(self.strings)
def method_one(self):
print('Method One')
for x in range(1, self.length + 1):
print(' '.join(self.strings[-x:]))
def method_two(self):
print('\nMethod Two')
for x in range(self.length - 1, -1, -1):
print(' '.join(self.strings[x:]))
def method_three(self):
print('\nMethod Three', end='')
x = self.length
while x != -1:
print(' '.join(self.strings[x:]))
x -= 1
if __name__ == '__main__':
pattern_twelve = Pattern_Twelve()
pattern_twelve.method_one()
pattern_twelve.method_two()
pattern_twelve.method_three()