From f2eca40fec153ae923380742ff351487d023f201 Mon Sep 17 00:00:00 2001 From: Liron-Mizrahi <91504420+lironmiz@users.noreply.github.com> Date: Mon, 2 Jan 2023 11:36:22 +0200 Subject: [PATCH] Create unit3_ex3.4.2.py --- unit3_ex3.4.2.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 unit3_ex3.4.2.py diff --git a/unit3_ex3.4.2.py b/unit3_ex3.4.2.py new file mode 100644 index 0000000..40e4514 --- /dev/null +++ b/unit3_ex3.4.2.py @@ -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) +