Saturday, May 22, 2021

Reverse display the lines in a file

Script

#!/usr/local/bin/python3.5

file_to_reverse = open('/Python-scripts/Memorable-Tests/Dharamsala-2017-K21.txt')

for line in reversed(list(file_to_reverse)):
  print(line, end='')


Background

kirands-vm.company.com: /Python-scripts >
kirands-vm.company.com: /Python-scripts > cat /Python-scripts/Memorable-Tests/Dharamsala-2017-K21.txt
India beat Australia by eight wickets after demolishing Australia for 137 in their second innings.
Ravindra Jadeja played a match winning knock for India in their first innings.
Bhuvneshwar Kumar, Umesh Yadav and Ravichandran Ashwin captured the key wickets.
David Warner once again failed to make any impact in the Test match and the series.
Kuldeep Yadav had an impressive debut, snaring four wickets for 68 runs on Day one.
India went on to win the series despite losing the first Test.
Australia have lost their last four series in India, starting in 2008.
kirands-vm.company.com: /Python-scripts >
kirands-vm.company.com: /Python-scripts >


Execution

Australia have lost their last four series in India, starting in 2008.
India went on to win the series despite losing the first Test.
Kuldeep Yadav had an impressive debut, snaring four wickets for 68 runs on Day one.
David Warner once again failed to make any impact in the Test match and the series.
Bhuvneshwar Kumar, Umesh Yadav and Ravichandran Ashwin captured the key wickets.
Ravindra Jadeja played a match winning knock for India in their first innings.
India beat Australia by eight wickets after demolishing Australia for 137 in their second innings.


No comments:

Post a Comment