Mar-22-2018, 02:22 AM
i am trying to find the cube root and print
2) here "i" i in range in line no 2 , does it initializes to zero for first iteration.Could you please explain the control how it is passing line by line
cube=-64 for i in range(abs(cube)+1): if i**3 >=abs(cube): break if i**3 !=abs(cube): print(cube," is not a perfect cube") else: if cube<0: i = -i print('Cube root of ' + str(cube) + ' is ' + str(cube))error is line no 4
Error:C:\Users\solas\Documents>cubert.py
File "C:\Users\s\Documents\cubert.py", line 4
passed all potential cube roots
^
SyntaxError: invalid syntax
1)sure there is a syntax error ?2) here "i" i in range in line no 2 , does it initializes to zero for first iteration.Could you please explain the control how it is passing line by line