PS/Baekjoon Online Judge

[백준 05949] Adding Commas [Python]

kimyoungrok 2024. 7. 10. 23:14
728x90

문제

Bessie is working with large numbers N (1 <= N <= 2,000,000,000) like 153920529 and realizes that the numbers would be a lot easier to read with commas inserted every three digits (as is normally done in the USA; some countries prefer to use periods every three digits). Thus, she would like to add commas: 153,920,529. Please write a program that does this.

입력

  • Line 1: A single integer: N

 

출력

  • Line 1: The integer N with commas inserted before each set of three digits except the first digits (as traditionally done in many cultures)

풀이

입력받은 수를 읽기 쉽도록 3자리마다 쉼표를 넣어 출력해주는 문제다.

format함수를 사용해 쉽게 풀이할 수 있다.


소스코드

보기


출처

https://www.acmicpc.net/problem/5949

728x90