i´ve trying to add and dictionary to a set, but theres some error getting me some troubles, i know that there is because of a Key not hasheable but i cannot find it
import openpyxl
from openpyxl import Workbook
bookSource = openpyxl.load_workbook('J:\BI_Proyect\sources\soucesInXLSX.xlsx')
ProgramasxUni = bookSource["ProgramasPorUniversidades"]
Ranking = bookSource["Universidades"]
def searchInRanking(nameUni, Uni):
for i in range(2, 574):
if(Ranking[f"B{i}"].value == Uni["Nombre"]):
Uni["fk_InternationalScore"] = Ranking[f"A{i}"].value
#Uni.update({"fk_InternationalScore": Ranking[f"A{i}"].value})
else:
Uni["fk_InternationalScore"] = None
thisSet = set()
for i in range(2, 255):
NAMEUNI=ProgramasxUni[f"A{i}"].value
Universidad = {
"Id" : i-1,
"Nombre": NAMEUNI,
}
searchInRanking(NAMEUNI, Universidad)
print(Universidad)
thisSet.add(Universidad)
print(thisSet)
print(thisSet)
printing the dict is something like this:
{'Id': 1, 'Nombre': 'Albright College', 'fk_InternationalScore': None}
And executing the code gives me this respond:
PS J:\BI_Proyect> & C:/Python39/python.exe j:/BI_Proyect/python_scripting/Universidades.py
{'Id': 1, 'Nombre': 'Albright College', 'fk_InternationalScore': None}
Traceback (most recent call last):
File "j:\BI_Proyect\python_scripting\Universidades.py", line 31, in <module>
thisSet.add(Universidad)
TypeError: unhashable type: 'dict'