You are viewing a single comment's thread. Return to all comments →
# using python's .center method: height, width = map(int, input().split()) pattern_list: list[str] = [] for i in range(1, height, 2): pattern_list.append((".|." * i).center(width, "-")) print(*pattern_list, sep="\n") print("WELCOME".center(width, "-")) print(*pattern_list[::-1], sep="\n") # vs # calculating patterns manually: height, width = map(int, input().split()) pattern_list: list[str] = [] for i in range(1, height, 2): dash_length: int = (width - (i * 3)) // 2 dash_line: str = "-" * dash_length line: str = dash_line + (".|." * i) + dash_line pattern_list.append(line) welcome_dash_length: int = (width - 7) // 2 welcome_dash_line: str = "-" * welcome_dash_length print(*pattern_list, sep="\n") print(welcome_dash_line + "WELCOME" + welcome_dash_line) print(*pattern_list[::-1], sep="\n")
Seems like cookies are disabled on this browser, please enable them to open this website
Designer Door Mat
You are viewing a single comment's thread. Return to all comments →