Skip to content

Commit fd6a5e4

Browse files
committed
Designer door mat
1 parent ee2693d commit fd6a5e4

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

Remove duplicate lines from Text file/remove_duplicate_lines.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Replace `sample_file_path.txt` with the location of desired text file to remove duplicate lines(full location path if it is not in the same directory as the code file and only the name if it is in the same directory as the code file).
33
A new text file "clean_text.txt" will be created in the same directory as the code file with no duplicate lines from `sample_file_path.txt`.
4+
45
"""
56

67
content = open('sample_file_path.txt','r').readlines()

String/DoorMat.py

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""
2+
Prints a door mat of size N * M (N is an odd natural number, and M is 3 times N).
3+
Input format:
4+
A single line containing the space separated values of N and M.
5+
"""
6+
7+
string_input = input()
8+
measurements = string_input.split()
9+
length = int(measurements[0])
10+
breadth = int(measurements[1])
11+
12+
triangle= ".|."
13+
line_number = 1
14+
half_height = length//2
15+
16+
# top part
17+
for i in range(half_height):
18+
print((triangle*line_number).center(breadth, '-'))
19+
line_number += 2
20+
21+
# center
22+
middle = "WELCOME"
23+
print(middle.center(breadth,'-'))
24+
25+
# lower part
26+
for i in range(half_height):
27+
print((triangle*(line_number-2)).center(breadth, '-'))
28+
line_number -= 2

0 commit comments

Comments
 (0)