Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1a9bfc0

Browse files
committed
Add new solution to match new exercise
1 parentdd45619 commit1a9bfc0

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)

[8]ページ先頭

©2009-2025 Movatter.jp