Python transform a number into integer

0
import math
x=9
raiz=math.sqrt(x)
print raiz
for i in range (raiz,9): #Problema aqui
 i=i**2
 print i

I need to create a for with the root of an operation (always integer 2, 3,4,5 ...) but when I try to use it the way I did the error. It says the root has to be integer (python understands like 2.0, 3.0, etc.) Does anyone know how I can handle isdso?

    
asked by anonymous 02.04.2018 / 04:14

1 answer

0

You need to convert raiz to integer

import math
x=9
raiz=math.sqrt(x)
print(raiz)
for i in range (int(raiz),9): #Problema aqui
    i=i**2
    print(i)
    
02.04.2018 / 04:26