¿Cómo divido las soluciones para mi código?

cuando le da un problema a mi código, le dice su problema, pero no puedo cambiarlo, por lo que tiene múltiples soluciones, ¿siempre da la misma solución a todos los diferentes problemas? Lo que estoy preguntando es cómo dar la solución correcta al problema correcto en lugar de todos los problemas que solo conducen a una solución donde dice “imprimir” (la solución a su problema es … “) me gustaría cambiarlo para que da una solución diferente a los diferentes problemas 🙂 gracias de antemano :))

PROBLEMS = (('My phone does not turn on.', {'power', 'turn', 'on', 'off'}), ('My phone is freezing.', {'freeze', 'freezing'}), ('The screen is cracked.', {'cracked', 'crack', 'broke', 'broken', 'screen'}), ('I dropped my phone in water.', {'water', 'drop', 'dropped'})) POSITIVE = tuple(map(str.casefold, ('yes', 'true','yeah', 'positive','thats right', 'yeah bro','yes', '1'))) NEGATIVE = tuple(map(str.casefold, ('no', 'false','na', 'not true','thats wrong', 'na bro','nope' '0'))) def main(): """Find out what problem is being experienced and provide a solution.""" description = input('Please describe the problem with your phone: ') words = {''.join(filter(str.isalpha, word)) for word in description.lower().split()} for problem, keywords in PROBLEMS: if words & keywords: print('This may be what you are experiencing:') print(problem) if get_response('Does this match your problem? '): print('The solution to your problem is ...') break else: print('Sorry, but I cannot help you.') def get_response(query): """Ask the user yes/no style questions and return the results.""" while True: answer = input(query).casefold() if answer: if any(option.startswith(answer) for option in POSITIVE): return True if any(option.startswith(answer) for option in NEGATIVE): return False print('Please provide a positive or negative answer.') if __name__ == '__main__': main() 

En función de su pregunta, el progtwig que se muestra a continuación se ha modificado para incluir también los pasos que se pueden tomar para resolver los problemas encontrados con un teléfono celular. Siguiendo las palabras clave, una lista de pasos ahora se incluye en la base de datos de PROBLEMS . Por favor, sustituya sus propios pasos para los dados. Los pasos proporcionados son ideas de muestra pero también basura en términos de tratar de ayudar a alguien. Puede agregar un número menor o mayor de pasos por solución si así lo desea.

 #! /usr/bin/env python3 # The following is a database of problems, keywords, and solutions. PROBLEMS = (('My phone does not turn on.', {'power', 'turn', 'on', 'off'}, ('Smack it with a hammer.', 'Wrap your phone in duck tape.', 'Throw it into the ocean.')), ('My phone is freezing.', {'freeze', 'freezing'}, ('Dowse it in a petroleum-based product.', 'Light a match or find a suitable flame source.', 'Barbecue your phone until it is well done.')), ('The screen is cracked.', {'cracked', 'crack', 'broke', 'broken', 'screen'}, ('Find some super glue.', 'Spread the super glue over the screen of the phone.', 'Either sit on the phone or place a 100 pounds over it.')), ('I dropped my phone in water.', {'water', 'drop', 'dropped'}, ('Blow dry your phone with air below zero degrees Celsius.', 'Bake it in your oven at three hundred degrees Celsius.', 'Leave your phone on your roof for one week.'))) # These are possible answers accepted for yes/no style questions. POSITIVE = tuple(map(str.casefold, ('yes', 'true', '1'))) NEGATIVE = tuple(map(str.casefold, ('no', 'false', '0'))) def main(): """Find out what problem is being experienced and provide a solution.""" description = input('Please describe the problem with your phone: ') words = {''.join(filter(str.isalpha, word)) for word in description.lower().split()} for problem, keywords, steps in PROBLEMS: if words & keywords: print('This may be what you are experiencing:') print(problem) if get_response('Does this match your problem? '): print('Please follow these steps to fix your phone:') for number, step in enumerate(steps, 1): print('{}. {}'.format(number, step)) print('After this, your phone should work.') print('If it does not, please take it to a professional.') break else: print('Sorry, but I cannot help you.') def get_response(query): """Ask the user yes/no style questions and return the results.""" while True: answer = input(query).casefold() if answer: if any(option.startswith(answer) for option in POSITIVE): return True if any(option.startswith(answer) for option in NEGATIVE): return False print('Please provide a positive or negative answer.') if __name__ == '__main__': main()