Mar-22-2018, 04:26 AM
The 'if' statement must have a code block. Perhaps that 'break' statement? If that is the case, the indentation is wrong.
range() starts with 0. In order to start with 1, for example, add it as a second parameter:
Do you initialize cube with a value of -64? Also, 'i' in line 9?
range() starts with 0. In order to start with 1, for example, add it as a second parameter:
range(var, 1)
.Do you initialize cube with a value of -64? Also, 'i' in line 9?
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))