write a program to read content of file and display 'I' in place of 'E' while displaying the content of the file all character should be as it is.please answer the question in python
Answers
Replacing text - Python
Since we are not given/mentioned in the Question that by what programming language we write the required program, so here we are using python program to read content of file and display 'I' in place of 'E' while displaying the content of the file all character should be as it is.
Before we write the required program for this question, let's first take some hint for better understanding and know that what we need to do in this program and how to write the program.
What we need to do
We would take a user input function first, to accept the texts from the user. We know that the function returns a string, string is one of the basis types in Python that store text.
After that, we will use the syntax to replace the texts, here's the syntax to replace the texts:
We then print out the file after replacing 'I' in place of 'E', by simply using function to print the file.
The Program
texts = input("Enter your file: ")
replace = texts.replace("I","E")
print(replace)
We can also short this program, so let's short the program, by changing something.
texts = input("Enter your file: ")
print(texts.replace("I","E"))
Do you know, we can also shorten this program further, so let's short the program more, by changing something.
print((input("Enter your file: ")).replace("I","E"))
Sample run
The output of the given program will be as follows:
Enter your file: Hello there, I'm Eldarion.
E'm Eldarion.
Replacing text - Python
Since we are not given/mentioned in the Question that by what programming language we write the required program, so here we are using python program to read content of file and display 'I' in place of 'E' while displaying the content of the file all character should be as it is.
Before we write the required program for this question, let's first take some hint for better understanding and know that what we need to do in this program and how to write the program.
What we need to do
We would take a user input function first, to accept the texts from the user. We know that the function returns a string, string is one of the basis types in Python that store text.
After that, we will use the syntax to replace the texts, here's the syntax to replace the texts:
We then print out the file after replacing 'I' in place of 'E', by simply using function to print the file.
The Program
texts = input("Enter your file: ")
replace = texts.replace("I","E")
print(replace)
We can also short this program, so let's short the program, by changing something.
texts = input("Enter your file: ")
print(texts.replace("I","E"))
Do you know, we can also shorten this program further, so let's short the program more, by changing something.
print((input("Enter your file: ")).replace("I","E"))
Sample run
The output of the given program will be as follows:
Enter your file: Hello there, I'm Anthony
Anthony Paul Villy