Skip to content

6 #10

Description

@legend17-dot

Read and display initial content
input_file = open("input.txt", "r")
lines = input_file.readlines()
input_file.close()
print("Initial Content:\n")
for line in lines:
print(line.strip())

Sort content

clean_lines = []
for line in lines:
text = line.strip()
if len(text) > 0:
clean_lines.append(text)
clean_lines.sort()
print("\nSorted Content:\n")
for item in clean_lines:
print(item)

Write sorted content to output file

output_file = open("output.txt", "w")
for item in clean_lines:
output_file.write(item + "\n")
output_file.close()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions