[이코테] 구현_럭키 스트레이트 (python)

juyeon·2022년 7월 17일
0

문제

: 짝수 자리수의 정수형이 주어짐.
자리수 반으로 나눠서 앞부분의 합과 뒷부분의 합이 같으면 LUCKY를, 다르면 READY를 출력

나의 풀이

1. 성공

# str로 input -> for문으로 원소 하나씩 int 변환
score = list(int(x) for x in input())
# 절반값
half = len(score) // 2

# 앞과 뒤를 각각 더한 값이 같다면
if sum(score[:half]) == sum(score[half:]):
	print('LUCKY')
else:
	print('READY')
  • score = list(map(lambda x: int(x), input()))로 해도 됨
profile
내 인생의 주연

0개의 댓글