for문과 while문 (python)

juyeon·2022년 7월 1일
0

데이터 다루기

목록 보기
3/35
  1. 문자열을 입력하여 첫글자와 마지막 글자를 붙여서 출력하고자 할 때. 단, 각 문자열마다 엔터

1) while문

i = 0
n = int(input())

while i < n:
    string = input()
    print(string[0], string[-1], sep = '')
    i += 1

2) for문

for i in range(int(input())):
    string = input()
    print(string[0], string[-1], sep = '')
profile
내 인생의 주연

0개의 댓글