내가 아는 방법 1 - 반복문 이용
x = int(input())
res = 0
while x>0:
t = x%10
res = res*10+t
x = x//10
print(res)
방법 2 - 문자열 이용
x = int(input())
print(int(str(x)[::-1]))
'programming > Python' 카테고리의 다른 글
[Python] for else 문 (0) | 2021.04.22 |
---|
내가 아는 방법 1 - 반복문 이용
x = int(input())
res = 0
while x>0:
t = x%10
res = res*10+t
x = x//10
print(res)
방법 2 - 문자열 이용
x = int(input())
print(int(str(x)[::-1]))
[Python] for else 문 (0) | 2021.04.22 |
---|
댓글