Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # tee ratkaisu tänne
- def spellchecker(dict: dict,spellcheck_text: str):
- words_case = spellcheck_text.split()
- words_lcase = []
- checked = ""
- # all strings to lowercase for comparison
- for val in words_case:
- words_lcase.append(val)
- for val in words_lcase:
- #print(dict["python"])
- if val.lower() in dict.keys():
- checked += f"{val} "
- else:
- checked += f"*{val}* "
- checked.rstrip()
- print(checked)
- def load_dict(filename):
- dict = {}
- with open(filename) as file:
- for word in file:
- dict[word.strip()] = 1
- return dict
- def main():
- dict = load_dict("wordlist.txt")
- spellcheck_text = input("Write text:") #"We use ptython to make a spell checker"
- spellchecker(dict, spellcheck_text)
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement