Python Program to Reverse the Content of a File using Stack
Given a file, the task is to print as well as store the lines of that file in reverse order using Stack.
Input : I am new to this world of Python. Output : Python. world of new to this I am Input : 1 2 3 4 5 Output : 5 4 3 2 1
- Create an empty stack.
- One by one push every line of the file to the stack.
- One by one pop each line from the stack and put them back to the file.
Below is the implementation.
This is a World of Geeks. Welcome to GeeksforGeeks.
My Personal Notes arrow_drop_up