Jun-24-2020, 09:05 AM
import sys from cs50 import get_string from cs50 import get_int from py_thesaurus import Thesaurus def main(): if len(sys.argv) != 2: print("Usage:python final.py read [or] thes") sys.exit(1) ui = string(sys.argv[1]) if ui == "read" T = get_string("Enter Text: ") DG = get_int("What grade do you need? ") length = len(T) letters = 0 S = T.count('.') + T.count('!') + T.count('?') W = T.count(' ') for i in range(length): if (T[i].isalpha()): letters += 1 L = letters / W * 100 S = S / W * 100 calculate = 0.0588 * L - 0.296 * S - 15.8 indexi = round(calculate) if (indexi == DG): print("You're right on!") if (indexi < DG): print("You need more. :( Consider longer words, sentences and/or paragraphs") if (indexi > DG): print("You passed your grade. Congrats!") if ui == "thes" input_word = get_string("Word-") synonym = (input_word.get_synonym) synonym_verb = (input_word.get_synonym(pos='verb')) synonym_adj = (input_word.get_synonym(pos='adj')) definition = (input_word.get_definition()) antonym = (input_word.get_antonym()) i = 0 while i < 1: print(f{synonym}) print(f{synonym_verb}) print(f{synonym_adj}) print(f{definition}) print(f{antonym}) i += 1 if __name__ == "__main__": main()
Error:#but I always get this error message:
File "final.py", line 13
if ui == "read"
^
SyntaxError: invalid syntax