Skip to content
Merged
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
22 changes: 22 additions & 0 deletions unit3_ex3.4.2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# exercise 3.4.2 from unit main
'''
Write a program that accepts a string of his choice from the user.
The program will print to the screen a string in which all occurrences
of the first character have been replaced by the character 'e', except for the first
character itself.

example:
Please enter a string: ddar astronaut. pldase, stop drasing md!
dear astronaut. please, stop erasing me!

'''

str = input("Enter a string: ")
char_to_replace = str[0]
if(len(str) > 1):
output = str[0] + str[1:].replace(char_to_replace, 'e')
else:
output = str[0]

print(output)