-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstrs_intro_exer.py
More file actions
27 lines (21 loc) · 1.17 KB
/
strs_intro_exer.py
File metadata and controls
27 lines (21 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# String Exercises for introtopython.org
quote = 'A quote from the Bible that I like: "If it is disagreeable in your sight to serve the Lord, choose for yourselves today whom you will serve: whether the gods which your fathers served which were beyond the River, or the gods of the Amorites in whose land you are living; but as for me and my house, we will serve the Lord."'
print(quote)
first_name = 'tony'
print(first_name) # prints string as listed originally
print(first_name.title()) # prints string with first letter capital
print(first_name.upper()) # prints string in all upper case
# storing full name in separate variables to concatenate and print
first_name = 'tony'
last_name = 'lettkeman'
print(first_name.title() + ' ' + last_name.title())
first_name = 'tony'
last_name = 'lettkeman'
print(first_name.title() + ' ' + last_name.title() + ' is a pretty stand up guy.')
name = ' Tony '
print('-' + name + '-') # printing name as is
# printing name with leading whitespace stripped
print('-' + name.lstrip() + '-')
# printing name with trailing whitespace stripped
print('-' + name.rstrip() + '-')
print('-' + name.strip() + '-') # printing name with all whitespace stripped