In [4]:
x = int(input("Enter an integer: ").strip())
ans = 0
while ans*ans*ans < abs(x):
    ans = ans + 1
if ans*ans*ans != abs(x):
    print(x, "is not a perfect cube")
else:
    if x < 0:
        ans = -ans
    print("Cube root of", str(x), "is", str(ans))


Enter an integer27
Cube root of 27 is 3

In [6]:
x = int(input("Enter an integer: ").strip())
for ans in range(0, abs(x)+1):
    if ans**3 == abs(x):
        break
if ans**3 != abs(x):
    print(x, "is not a perfect cube")
else:
    if x < 0:
        ans = -ans
    print("Cube root of", str(x), "is", str(ans))


Enter an integer: 27
Cube root of 27 is 3

In [ ]: