Read the specified text file into memory and write it in reverse order to another text file | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

Read the specified text file into memory and write it in reverse order to another text file

Help pls, i don't know

14th Mar 2023, 3:01 PM
Nadia Badeiko
Nadia Badeiko - avatar
4 Respostas
+ 1
Herobrine This looks like Python, not C as the OP tagged. Also, please try not give complete answers to questions. It is best to ask for their attempt first and then guide them closer to finding the solution on their own.
14th Mar 2023, 3:42 PM
Justice
Justice - avatar
0
# Open the file in write mode f1 = open("output1.txt", "w") Ā  # Open the input file and get # the content into a variable data with open("file.txt", "r") as myfile: Ā Ā Ā Ā data = myfile.read() Ā  # For Full Reversing we will store the # value of data into new variable data_1 # in a reverse order using [start: end: step], # where step when passed -1 will reverse # the string data_1 = data[::-1] Ā  # Now we will write the fully reverse # data in the output1 file using # following command f1.write(data_1) Ā  f1.close()
14th Mar 2023, 3:11 PM
Herobrine
Herobrine - avatar
0
Eg if you input š™œš™¤š™¤š™™ Output will be š™™š™¤š™¤š™œ
14th Mar 2023, 3:12 PM
Herobrine
Herobrine - avatar
0
If I am wrong please correct me
14th Mar 2023, 3:12 PM
Herobrine
Herobrine - avatar