10000 Add new solution to match new exercise · madamak/python-basics-exercises@1a9bfc0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1a9bfc0

Browse files
committed
Add new solution to match new exercise
1 parent dd45619 commit 1a9bfc0

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

ch04-strings-and-string-methods/8-find-a-string-in-a-string.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88

99

1010
# Exercise 2
11-
# Try to find a number inside a string;
12-
# use str() to convert the number first
13-
version = "version 2.0"
14-
v_num = 2.0
15-
print(version.find(str(v_num)))
11+
# Replace every occurrence of the character `"s"`
12+
# with the character `"x"`
13+
phrase = "Somebody said something to Samantha."
14+
phrase = phrase.replace("s", "x")
15+
print(phrase)
16+
# NOTE: This leaves the capital "S" unchanged, so the
17+
# output will be "Somebody xaid xomething to Samantha."
1618

1719

1820
# Exercise 3

0 commit comments

Comments
 (0)
0