Skip to content

Commit

Permalink
End reto
Browse files Browse the repository at this point in the history
  • Loading branch information
rigo93acosta committed Sep 21, 2024
1 parent ff7e354 commit 4fe8891
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Roadmap/36 - EL SOMBRERO SELECCIONADOR/python/rigo93acosta.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* pero indicándole al alumno que la decisión ha sido complicada).
*/
'''
import random

houses = {
"Frontend": 0,
Expand Down Expand Up @@ -238,3 +239,31 @@
}
]

print("¡Bienvenido al Hogwarts para magos y brujas del código!")
print("El sombrero seleccionador te ayudará a encontrar tu casa ideal.")
name = input("¿Cuál es tu nombre? ")

for index, question in enumerate(questions):
print(f"\nPregunta {index + 1}: {question['question']}\n")

for i, answer in enumerate(question['answers']):
print(f"{i + 1}. {answer['option']}")

choice = int(input("\nElige una opción (1-4): "))
house = question['answers'][choice - 1]['house']
houses[house] += 1

print(f"\n¡{name.capitalize()}! El sombrero seleccionador ha tomado una decisión...")
assig_house = max(houses, key=houses.get)
scores = list(houses.values())

if scores.count(max(scores)) > 1:
print(f"Hmmmm.... La decisión ha sido complicada, pero......")
possible_houses = [
house for house, points in houses.items() if points == max(scores)
]
assig_house = random.choice(possible_houses)
print(f"¡{name.capitalize()} tu casa es... {assig_house}!")
else:
print(f"¡{name.capitalize()} tu casa es... {assig_house}!")

0 comments on commit 4fe8891

Please sign in to comment.