Allen's 데이터 맛집

[Python] 기초문법 : 왼쪽, 오른쪽 정렬 본문

Programming/Python

[Python] 기초문법 : 왼쪽, 오른쪽 정렬

Allen93 2023. 11. 17. 01:33

 

.ljust() 는 왼쪽으로 정렬, 

.rjust() 는 오른쪽 정렬

()  안의 매개변수는 어느정도 공백을 두는지

scores = {'수학':0,'영어':50,'코딩':100}

for subject, socore in scores.items():
    print(subject.ljust(8), str(socore).rjust(4), sep = ":")

>>> 수학 : 0영어 : 50코딩 : 100

728x90