Advertisement
Aikiro42

Untitled

Oct 13th, 2019
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.45 KB | None | 0 0
  1. dictionary = []  # Renamed x and all references to it to dictionary for readability
  2. queries = []  # Renamed y and all references to it to queries for readability
  3. printer = []
  4.  
  5. n = 0
  6. while n != "XXXXXX":
  7.     n = input()
  8.     if n != "XXXXXX":
  9.         dictionary.append(n)
  10.  
  11. n = 0
  12. while n != "XXXXXX":
  13.     n = input()
  14.     if n != "XXXXXX":
  15.         queries.append(n)
  16.  
  17. dict_copy = dictionary.copy()
  18. dictionary.sort()
  19. dict_copy.sort()
  20.  
  21. i = 0
  22. while i < len(dictionary):
  23.     # dictionary[i] = ''.join(sorted(set(dictionary[i])))
  24.     dictionary[i] = ''.join(sorted(list(dictionary[i])))
  25.     i += 1  # Restated increment statement
  26.  
  27. i = 0
  28. while i < len(queries):
  29.     # queries[i] = ''.join(sorted(set(queries[i])))
  30.     queries[i] = ''.join(sorted(list(queries[i])))
  31.     i = i + 1
  32.  
  33. query_index = 0  # Renamed i to query_index for readability
  34. while query_index < len(queries):
  35.     dict_index = 0  # Renamed q to query_index for readability
  36.     while dict_index < len(dictionary):
  37.         if queries[query_index] == dictionary[dict_index]:
  38.             printer.append(dict_copy[dict_index])
  39.         dict_index += 1  # Restated increment statement for dict_index
  40.     printer.append("******")
  41.     i += 1  # Restated increment statement
  42.  
  43. for g in range(len(printer) - 1):
  44.     if printer[g] == printer[g + 1]:
  45.         printer.insert(g + 1, "NOT A VALID WORD")
  46.  
  47. i = 0
  48. while i < len(printer):
  49.     print(printer[i])
  50.     i += 1  # Restated increment statement
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement