1. Read a text file line by line and display each word separated by a #.

 


defread_and_display_words(filename):

with open(filename, 'r') as file:

for line in file:

words = line.split()

print("#".join(words))

 

if __name__ == "__main__":

filename = "input.txt"  # Replace with your file name

read_and_display_words(filename)

No comments:

Post a Comment