BOJ/백준-9093-python

cosmos·2022년 3월 12일
0
post-thumbnail

문제

풀이

  • 첫째 줄에 테스트 케이스의 개수 t가 주어진다.
  • 각 테스트 케이스에 대해서, 입력으로 주어진 문장의 단어를 모두 뒤집어 출력한다.
    -> list로 문자열을 입력받은 후, 슬라이싱으로 뒤집어서 출력하여 구현하였다.

코드

# https://www.acmicpc.net/problem/9093
# boj, 9093: 단어 뒤집기, python3
def solve(word):
    result = ''
    
    for x in word:
        result += x[::-1] + ' '

    return result[:-1]


if __name__ == '__main__':
    t = int(input())
    words = [list(map(str, input().split())) for _ in range(t)]

    for word in words:
        print(solve(word))

결과

출처 & 깃허브

BOJ 9093
GITHUB

0개의 댓글