Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
Here in Python, I created a program for this challenge and I'm having trouble debugging it. I already fixed most errors I have on my program but here's what I have left: x=y=z=[];i=0.0;a=int(input...
#3: Post edited
- Here in Python, I created a program for [this challenge](https://codegolf.codidact.com/posts/282244) and I'm having trouble debugging it. I already fixed most errors I have on my program but here's what I have left:
- ```python
- x=y=z=[];i=0.0;a=int(input());b=0
- for c in range(1,a+1):
- for d in range(1,a):
- i+=1
- if a/c==i and c!=a:b+=c
- if b<a:x.append(c)
- elif b>a:y.append(c)
- else:z.append(c)
- i=b=0
- print("[",end='')
- for j in x:
- print(j,end='')
- if j!=len(x):print(" ",end='')
- print("], [",end='')
- for j in y:
- print(j,end='')
- if j!=len(y):print(" ",end='')
- print("], [",end='')
- for j in z:
- print(j,end='')
- if j!=len(z):print(" ",end='')
- print("]",end='')
- ```
- Basically, I'm trying to make a number checker so I can get the inputted number's proper divisor sum, which in my understanding is the sum of divisors that results in a quotient that can be formatted as `n.00000...`, but the resulting output leaves me with all the numbers from 1 to the input. [See it for yourself! (SIFY)](https://tio.run/##lY5fC4IwFEef9VOsXtpQSoleZrcvIj5c56qJrGEGzi9v3Yr@QAg9Dc6Pe3ac744nux7HHjwMkBeZgWSZZAjGdtxYd@m4EFkJSbg/tUwxY1mL9qB5GmOUChkGxKsvTjQwEaT07BmuFIBhaCumZoCyjECFNJRblP0SndO24kqEgW6I7lD6b3rWcvgkBijItdQ4z@fxjcNiIe6JNaX0t4LHXL9G@rGeQaMt74V8HrP38ZMUMftl9NNG/79xmDYOU8YXGcd0cwU)
- I've been trying to figure out where the problem lies and I suspect it has to do with the first `for` loop, but I don't know where exactly to fix. Where did I mess up or how do I fix this?
- Here in Python, I created a program for [this challenge](https://codegolf.codidact.com/posts/282244) and I'm having trouble debugging it. I already fixed most errors I have on my program but here's what I have left:
- ```python
- x=y=z=[];i=0.0;a=int(input());b=0
- for c in range(1,a+1):
- for d in range(1,a):
- i+=1
- if a/c==i and c!=a:b+=c
- if b<a:x.append(c)
- elif b>a:y.append(c)
- else:z.append(c)
- i=b=0
- print("[",end='')
- for j in x:
- print(j,end='')
- if j!=len(x):print(" ",end='')
- print("], [",end='')
- for j in y:
- print(j,end='')
- if j!=len(y):print(" ",end='')
- print("], [",end='')
- for j in z:
- print(j,end='')
- if j!=len(z):print(" ",end='')
- print("]",end='')
- ```
- Here's the unshortened code with comments:
- ```
- x=y=z=[] # Initialize up 3 empty lists
- i=0.0 # initialize a float to make sure the numbers would be checked if it's a proper divisor
- a=int(input()) # input an integer
- b=0 # initialize the value for the proper divisor sum
- for c in range(1,a+1): # start a for loop that checks which list should the number in the range of 1 and the input
- for d in range(1,a): # start a for loop to get the proper divisor sum of each number in the range of 1 and the input
- i+=1 # increment 1 for rechecking
- if a/c==i and c!=a: # check if the number is a proper divisor
- b+=c # if it is, then add it to the sum
- if b<a:
- x.append(c) # add to the list if the number is deficient
- elif b>a:
- y.append(c) # add to the list if the number is abundant
- else:
- z.append(c) # add to the list if the number is perfect
- i=b=0 # reset the numbers for rechecking
- print("[", end = '') # start the output by adding a bracket without a newline
- for j in x: # print all deficient numbers as a list
- print(j, end = '') # print the number according to the for loop without a newline
- if j != len(x):
- print(" ", end = '') # print a space to separate numbers without a newline except for the last number in the list
- print("], [", end = '') # End the list, proceed to the next one
- for j in y: # print all abundant numbers as a list
- print(j, end = '') # print the number according to the for loop without a newline
- if j != len(y):
- print(" ", end = '') # print a space to separate numbers without a newline except for the last number in the list
- print("], [", end = '') # End the list, proceed to the next one
- for j in z: # print all perfect numbers as a list
- print(j, end = '') # print the number according to the for loop without a newline
- if j != len(z):
- print(" ", end = '') # print a space to separate numbers without a newline except for the last number in the list
- print("]", end = '') # end it with a bracket
- ```
- Basically, I'm trying to make a number checker so I can get the inputted number's proper divisor sum, which in my understanding is the sum of divisors that results in a quotient that can be formatted as `n.00000...`, but the resulting output leaves me with all the numbers from 1 to the input. [See it for yourself! (SIFY)](https://tio.run/##lY5fC4IwFEef9VOsXtpQSoleZrcvIj5c56qJrGEGzi9v3Yr@QAg9Dc6Pe3ac744nux7HHjwMkBeZgWSZZAjGdtxYd@m4EFkJSbg/tUwxY1mL9qB5GmOUChkGxKsvTjQwEaT07BmuFIBhaCumZoCyjECFNJRblP0SndO24kqEgW6I7lD6b3rWcvgkBijItdQ4z@fxjcNiIe6JNaX0t4LHXL9G@rGeQaMt74V8HrP38ZMUMftl9NNG/79xmDYOU8YXGcd0cwU)
- I've been trying to figure out where the problem lies and I suspect it has to do with the first `for` loop, but I don't know where exactly to fix. Where did I mess up or how do I fix this?
#2: Post edited
Where did my proper divisor sum program went wrong?
- Here in Python, I created a program for [this challenge](https://codegolf.codidact.com/posts/282244) and I'm having trouble debugging it. I already fixed most errors I have on my program but here's what I have left:
```- x=y=z=[];i=0.0;a=int(input());b=0
- for c in range(1,a+1):
- for d in range(1,a):
- i+=1
- if a/c==i and c!=a:b+=c
- if b<a:x.append(c)
- elif b>a:y.append(c)
- else:z.append(c)
- i=b=0
- print("[",end='')
- for j in x:
- print(j,end='')
- if j!=len(x):print(" ",end='')
- print("], [",end='')
- for j in y:
- print(j,end='')
- if j!=len(y):print(" ",end='')
- print("], [",end='')
- for j in z:
- print(j,end='')
- if j!=len(z):print(" ",end='')
- print("]",end='')
- ```
- Basically, I'm trying to make a number checker so I can get the inputted number's proper divisor sum, which in my understanding is the sum of divisors that results in a quotient that can be formatted as `n.00000...`, but the resulting output leaves me with all the numbers from 1 to the input. [See it for yourself! (SIFY)](https://tio.run/##lY5fC4IwFEef9VOsXtpQSoleZrcvIj5c56qJrGEGzi9v3Yr@QAg9Dc6Pe3ac744nux7HHjwMkBeZgWSZZAjGdtxYd@m4EFkJSbg/tUwxY1mL9qB5GmOUChkGxKsvTjQwEaT07BmuFIBhaCumZoCyjECFNJRblP0SndO24kqEgW6I7lD6b3rWcvgkBijItdQ4z@fxjcNiIe6JNaX0t4LHXL9G@rGeQaMt74V8HrP38ZMUMftl9NNG/79xmDYOU8YXGcd0cwU)
- I've been trying to figure out where the problem lies and I suspect it has to do with the first `for` loop, but I don't know where exactly to fix. Where did I mess up or how do I fix this?
- Here in Python, I created a program for [this challenge](https://codegolf.codidact.com/posts/282244) and I'm having trouble debugging it. I already fixed most errors I have on my program but here's what I have left:
- ```python
- x=y=z=[];i=0.0;a=int(input());b=0
- for c in range(1,a+1):
- for d in range(1,a):
- i+=1
- if a/c==i and c!=a:b+=c
- if b<a:x.append(c)
- elif b>a:y.append(c)
- else:z.append(c)
- i=b=0
- print("[",end='')
- for j in x:
- print(j,end='')
- if j!=len(x):print(" ",end='')
- print("], [",end='')
- for j in y:
- print(j,end='')
- if j!=len(y):print(" ",end='')
- print("], [",end='')
- for j in z:
- print(j,end='')
- if j!=len(z):print(" ",end='')
- print("]",end='')
- ```
- Basically, I'm trying to make a number checker so I can get the inputted number's proper divisor sum, which in my understanding is the sum of divisors that results in a quotient that can be formatted as `n.00000...`, but the resulting output leaves me with all the numbers from 1 to the input. [See it for yourself! (SIFY)](https://tio.run/##lY5fC4IwFEef9VOsXtpQSoleZrcvIj5c56qJrGEGzi9v3Yr@QAg9Dc6Pe3ac744nux7HHjwMkBeZgWSZZAjGdtxYd@m4EFkJSbg/tUwxY1mL9qB5GmOUChkGxKsvTjQwEaT07BmuFIBhaCumZoCyjECFNJRblP0SndO24kqEgW6I7lD6b3rWcvgkBijItdQ4z@fxjcNiIe6JNaX0t4LHXL9G@rGeQaMt74V8HrP38ZMUMftl9NNG/79xmDYOU8YXGcd0cwU)
- I've been trying to figure out where the problem lies and I suspect it has to do with the first `for` loop, but I don't know where exactly to fix. Where did I mess up or how do I fix this?
#1: Initial revision
Where did my proper divisor sum program went wrong?
Here in Python, I created a program for [this challenge](https://codegolf.codidact.com/posts/282244) and I'm having trouble debugging it. I already fixed most errors I have on my program but here's what I have left: ``` x=y=z=[];i=0.0;a=int(input());b=0 for c in range(1,a+1): for d in range(1,a): i+=1 if a/c==i and c!=a:b+=c if b<a:x.append(c) elif b>a:y.append(c) else:z.append(c) i=b=0 print("[",end='') for j in x: print(j,end='') if j!=len(x):print(" ",end='') print("], [",end='') for j in y: print(j,end='') if j!=len(y):print(" ",end='') print("], [",end='') for j in z: print(j,end='') if j!=len(z):print(" ",end='') print("]",end='') ``` Basically, I'm trying to make a number checker so I can get the inputted number's proper divisor sum, which in my understanding is the sum of divisors that results in a quotient that can be formatted as `n.00000...`, but the resulting output leaves me with all the numbers from 1 to the input. [See it for yourself! (SIFY)](https://tio.run/##lY5fC4IwFEef9VOsXtpQSoleZrcvIj5c56qJrGEGzi9v3Yr@QAg9Dc6Pe3ac744nux7HHjwMkBeZgWSZZAjGdtxYd@m4EFkJSbg/tUwxY1mL9qB5GmOUChkGxKsvTjQwEaT07BmuFIBhaCumZoCyjECFNJRblP0SndO24kqEgW6I7lD6b3rWcvgkBijItdQ4z@fxjcNiIe6JNaX0t4LHXL9G@rGeQaMt74V8HrP38ZMUMftl9NNG/79xmDYOU8YXGcd0cwU) I've been trying to figure out where the problem lies and I suspect it has to do with the first `for` loop, but I don't know where exactly to fix. Where did I mess up or how do I fix this?