Skip to content

Commit f2eca40

Browse files
authored
Create unit3_ex3.4.2.py
1 parent dd06ec1 commit f2eca40

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

unit3_ex3.4.2.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# exercise 3.4.2 from unit main
2+
'''
3+
Write a program that accepts a string of his choice from the user.
4+
The program will print to the screen a string in which all occurrences
5+
of the first character have been replaced by the character 'e', except for the first
6+
character itself.
7+
8+
example:
9+
Please enter a string: ddar astronaut. pldase, stop drasing md!
10+
dear astronaut. please, stop erasing me!
11+
12+
'''
13+
14+
str = input("Enter a string: ")
15+
char_to_replace = str[0]
16+
if(len(str) > 1):
17+
output = str[0] + str[1:].replace(char_to_replace, 'e')
18+
else:
19+
output = str[0]
20+
21+
print(output)
22+

0 commit comments

Comments
 (0)