Hello Katrine,
I probably comes from the Ti2 misspelled as T2i in the equation of T1==...
I found it by running your code with the Print section inside the loop for more visibility. The first iteration gave a numerical output + a remaining variable T2i. When you correct the spelling, the loop executes immediately.
Best regards
Christian NĂ©el