I made a program that would make an account, store the name of the account to one file, and store all of the account's information to another file. To store all of the account names in a list on running the program I use this code:
account_names = []
def account_names_adder():
try:
with open('Account_Names') as namesfile:
names = namesfile.readlines()
except FileNotFoundError:
None
else:
for name in names:
if name.strip() == '':
names.remove(name)
else:
account_names.append(name)
account_names_adder()
This is supposed to delete any whitespace and only account for strings with actual values to store in the list. However this is deleting the very first string with a value and not storing it in the list even though all other strings with values get appended. If I remove the .strip() it shows the first value, why is this? The program ran just fine one day ago and was never changed.