Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit fd6a5e4

Browse files
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‎

Lines changed: 1 addition & 0 deletions
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‎

Lines changed: 28 additions & 0 deletions
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)

AltStyle によって変換されたページ (->オリジナル) /