Python: Elemente einer Liste in Int umwandeln?
Ich habe folgende Übungsaufgabe. Die gegebene Lösung ist mit meiner Lösung identisch aber Python spuckt eine Fehlermeldung aus.
my_list = list[range(11)]
my_set = set()
for x in my_list:
if x%2==0:
my_set.add(x**2)
print(my_set)
TypeError: unsupported operand type(s) for %: 'types.GenericAlias' and 'int'
Python weist auf die Zeile "if x%2==0:" hin.
Das interpretiere ich so als muss ich die Elemente von my_list in int() setzen. Wie mache ich das? Ich habe schon das ein oder andere ausprobiert wie das simpelste x = int(x) und Google gefragt aber nichts hat funktioniert.