Untitled

mail@pastecode.io avatarunknown
python
a month ago
448 B
5
Indexable
Never
def remove_username_from_file(username, file_path):
    with open(file_path, 'r') as file:
        lines = file.readlines()
    with open(file_path, 'w') as file:
        indicelinea = 0
        for line in lines:
            
            for user in username:
                if line.strip() == user.strip():
                    del lines[indicelinea]
                    file.writelines(lines)
                indicelinea +=1