-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathstring-methods.py
More file actions
26 lines (21 loc) · 854 Bytes
/
string-methods.py
File metadata and controls
26 lines (21 loc) · 854 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
25
26
'''
String Methods
100xp
Strings come with a bunch of methods. Follow the instructions closely to discover some of them. If
you want to discover them in more detail, you can always type help(str) in the IPython Shell.
A string room has already been created for you to experiment with.
Instructions
-Use the upper() method on room and store the result in room_up. Use the dot notation.
-Print out room and room_up. Did both change?
-Print out the number of o's on the variable room by calling count() on room and passing the
letter "o" as an input to the method. We're talking about the variable room, not the word "room"!
'''
# string to experiment with: room
room = "poolhouse"
# Use upper() on room: room_up
room_up = room.upper()
# Print out room and room_up
print(room)
print(room_up)
# Print out the number of o's in room
print(room.count('o'))