Given a text file. The task is to reverse a single line of user’s choice from a given text file and update the already existing file.
Input: Hello Geeks for geeks! User choice = 1 Output: Hello Geeks geeks! for Input: This is a geek Welcome to GeeksforGeeks GeeksforGeeks is a computer science portal User choice = 0 Output: geek a is This Welcome to GeeksforGeeks GeeksforGeeks is a computer science portal
Let’s suppose the text file looks like this –
- Python program to reverse the content of a file and store it in another file
- Python program to extract Email-id from URL text file
- Python Program to Reverse the Content of a File using Stack
- Python program to Count the Number of occurrences of a key-value pair in a text file
- Read a file line by line in Python
- Convert Text and Text File to PDF using Python
- Transpose a matrix in Single line in Python
- Multiplication of two Matrices in Single line using Numpy in Python
- Extract text from PDF File using Python
- Saving Text, JSON, and CSV to a File in Python
- Extract numbers from a text file and add them using Python
- Convert Text file to JSON in Python
- Python | Scramble words from a text file
- Python | Finding 'n' Character Words in a Text File
- Count number of lines in a text file in Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.