Aug-17-2020, 12:27 AM
Hi all!
I need a bit of help ignoring a list item, I have a list of names with a "Y" at then end of each name and I want to ignore names without a "Y", my code is below:
I need a bit of help ignoring a list item, I have a list of names with a "Y" at then end of each name and I want to ignore names without a "Y", my code is below:
from time import strftime # import time print("Report date: " + strftime("%d/%m/%Y")) #Prints clock time with open("confPack.txt", "r") as confPack: # open file as confpack cPack = confPack.read().splitlines() # create cpak variable with open("employees.txt") as fp: for line in fp: values = line.strip().split(",") surname = values[0] firstName = values[1] # is the last value not a Y (meaning no Y's) # if that's false, meaning there is a Y, is the one before it a Y too if values[-1] != 'Y': print(" did not attend ") elif values[-2] == 'Y': packs = print(cPack[1]) else: packs = print(cPack[0]) print(f"Attendee: {surname}, {firstName}: {packs}")Thanks in advance!