Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions 1_beginner/chapter7/practice/replace.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
"""
Replace

Write a Python program to print a string
from a given string where all occurrences
of its first char have been changed to '$',
Write a Python program that asks the user for a string
and then prints a version of that string
where all occurrences of its first char
have been changed to '$',
except the first char itself.
Sample String : 'restart'
Expected Result : 'resta$t'

Sample Input: 'restart'
Expected Output: 'resta$t'

Adapted from W3Resource, problem 4:
https://www.w3resource.com/python-exercises/string/
Expand Down
3 changes: 2 additions & 1 deletion 1_beginner/chapter7/practice/upper.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Upper
# Continuously ask a user to enter words.
# (Make sure that the input given is actually just 1 word.)
# You should remove leading/trailing whitespace, and then
# make sure that the word is only made up of letters.
# Store the words in a list.
# Stop asking the user for words if they enter an empty string
# (the string has no characters or is completely whitespace).
Expand Down
11 changes: 6 additions & 5 deletions 1_beginner/chapter7/solutions/replace.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
"""
Replace

Write a Python program to print a string
from a given string where all occurrences
of its first char have been changed to '$',
Write a Python program that asks the user for a string
and then prints a version of that string
where all occurrences of its first char
have been changed to '$',
except the first char itself.

Sample String: 'restart'
Expected Result: 'resta$t'
Sample Input: 'restart'
Expected Output: 'resta$t'

Adapted from W3Resource, problem 4:
https://www.w3resource.com/python-exercises/string/
Expand Down
3 changes: 2 additions & 1 deletion 1_beginner/chapter7/solutions/upper.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Upper
# Continuously ask a user to enter words.
# (Make sure that the input given is actually just 1 word.)
# You should remove leading/trailing whitespace, and then
# make sure that the word is only made up of letters.
# Store the words in a list.
# Stop asking the user for words if they enter an empty string
# (the string has no characters or is completely whitespace).
Expand Down