Python Forum
need help what is the error here
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
need help what is the error here
#2
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: 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))
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Messages In This Thread
need help what is the error here - by m123 - Mar-22-2018, 02:22 AM
RE: need help what is the error here - by wavic - Mar-22-2018, 04:26 AM
RE: need help what is the error here - by m123 - Mar-24-2018, 04:52 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020