Python program to Reverse a single line of a text file
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.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course
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 –