-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathex_03_3.py
More file actions
24 lines (19 loc) · 714 Bytes
/
ex_03_3.py
File metadata and controls
24 lines (19 loc) · 714 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/python
#AUTHOR: alexxa
#DATE: 24.12.2013
#SOURCE: Think Python: How to Think Like a Computer Scientist by Allen B. Downey
# http://www.greenteapress.com/thinkpython/html/index.html
#PURPOSE: Chapter 3. Functions
# Exercise 3.3
# Write a function named right_justify that takes a string named s
# as a parameter and prints the string with enough leading spaces
# so that the last letter of the string is in column 70 of the display.
# >>> right_justify('allen')
# allen
def right_justify(s):
length = len(s)
num_of_spaces = 70 - length
print(' '*num_of_spaces, s)
right_justify('allen'*14)
right_justify('allen')
#END