openfile = open('number.txt', 'r') # split the word of file file = openfile.read().split(" ") openfile.close() # itretive functoin for add into the linkedlist for i in file: linkNode = Node(int(i)) listobj.sortlinklist(linkNode) listobj.printList() # take user input for search number = int(input("enter the number for search :")) # call the function search result = listobj.search(number) print(result) if result: listobj.delete_word(number) print("After Searching element in the list ") #after removing the element listobj.printList() #Delete the word form the file by over writting. file = open('number.txt', 'w') file.write('') file.close() print("\nthe word is deleted.....") else: listobj.add(number) print("After searching element in the list ") # after adding the element Unordered list listobj.printList() # adding the word to file add_word = Node(number)
# split the word of file file = openfile.read().split(" ") openfile.close() # itretive functoin for add into the linkedlist for i in file: listobj.add(i) # print the linked list listobj.printList() # use input word = str(input("\nenter the word for check:")) # call the function search result = listobj.search(word) print(result) if result: listobj.delete_word(word) print("After Searching element in the list ") #after removing the element listobj.printList() #Delete the word form the file by over writting. file = open('abc.txt', 'w') file.write('') length = listobj.size() f = open('abc.txt', 'a+') # write word of linked list into the file for i in range(0, length): file.write(" " + listobj.index(i)) file.close() print("\nthe word is deleted.....") else: