I use the '/' special character to split each word in the text file. The code output is as follows:
Mariam / AI / DS / ML
Steeve / DM / CO / DBMS / ML
Peter / DS / CO / MDS / ML
Stella / AI / DS / ML / DSAD
Martin / AI / ML / DS / MDS
I'm aiming to separate every word in the file. The code I developed to solve this problem is available below:
import os
desktop = os.path.join(os.path.expanduser("~"), "Desktop")
filePath = os.path.join(desktop, "inputPS13.txt")
file2 = open(filePath)
line1=file2.readline()
print("file is opened")
while(line1!=""):
print(line1)
line1=file2.readline()
for line in file2:
for word in line.split("/"):
print(word)