0
여기 내 코드의 단축 버전이 있습니다. 기본적으로 아스키 문자가 들어있는 목록을 저장하는 사전이 있습니다. 나는 특별한 디자인으로 인쇄 할 편지의 선택을 요구한다. 두 번째 사용자 입력은 문자 인쇄 방법을 결정하는 데 사용됩니다. 'h'= 가로, 'v'= 세로. 수직 단면은 완벽하게 작동합니다. 수평선은 그렇지 않습니다.파이썬, 사전에서 별도의 색인 인쇄
def print_banner(input_string, direction):
'''
Function declares a list of ascii characters, and arranges the characters in order to be printed.
'''
ascii_letter = {'a': [" _______ ",
"( ___ )",
"| ( ) |",
"| (___) |",
"| ___ |",
"| ( ) |",
"|) (|",
"|/ \|"]}
# Branch that encompasses the horizontal banner
if direction == "h":
# Letters are 8 lines tall
for i in range(8):
for letter in range(len(input_string)):
# Dict[LetterIndex[ListIndex]][Line]
print(ascii_letter[input_string[letter]][i], end=" ")
print(" ")
# Branch that encompasses the vertical banner
elif direction == "v":
for letter in input_string:
for item in ascii_letter[letter]:
print(item)
def main():
user_input = input("Enter a word to convert it to ascii: ").lower()
user_direction = input("Enter a direction to display: ").lower()
print_banner(user_input, user_direction)
# This is my desired output if input is aa
_______ _______
( ___ ) ( ___ )
| ( ) | | ( ) |
| (___) | | (___) |
| ___ | | ___ |
| ( ) | | ( ) |
|) (| |) (|
|/ \| |/ \|
#What i get instead is:
_______
_______
( ___ )
( ___ )
| ( ) |
| ( ) |
| (___) |
| (___) |
| ___ |
| ___ |
| ( ) |
| ( ) |
|) (|
|) (|
|/ \|
|/ \|
당신은 거의 오른쪽에만 두 번째 인쇄 될해야했다 들여 쓰기를하지 않는다. – skrx