#!/usr/bin/env python3 import re import sys import time s = sys.stdin.read() ans = set(re.findall(r'[\w]+', s.lower())) # convert answer to lowercase ans.difference_update({'e', 'a', 'o', 'planeta', 'planetas'}) # ignore words # correct set of planets planets = {'mercúrio', 'vénus', 'terra'} correct = set.intersection(ans, planets) # the ones I got right wrong = set.difference(ans, planets) # the ones I got wrong grade = (len(correct) - len(wrong)) / len(planets) comments = 'Certo' if grade == 1.0 else 'as iniciais dos planetas são M, V e T' out = f'''--- grade: {grade} comments: {comments}''' time.sleep(1) print(out)