Listing 09-05: Processing a file

##############################################################################
# Python From Scratch
# Autor: Nilo Ney Coutinho Menezes
# Editora Novatec (c) 2010-2024
# Site: https://pythonfromscratch.com
#
# File: listing\chapter 09\09.05 - Processing a file.py
# Description: Processing a file
##############################################################################

WIDTH = 79
with open("input.txt") as entries:
    for line in input.readlines():
        if line[0] == ";":
            continue
        elif line[0] == ">":
            print(line[1:].rjust(WIDTH))
        elif line[0] == "*":
            print(line[1:].center(WIDTH))
        else:
            print(line)
Click here to download the file