Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

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

70%
+5 −1
Q&A Where did my proper divisor sum program went wrong?

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...

1 answer  ·  posted 3y ago by General Sebast1an‭  ·  last activity 3y ago by hkotsubo‭

Question python debugging
#3: Post edited by (deleted user) · 2021-06-20T14:48:37Z (over 3 years ago)
  • 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 by (deleted user) · 2021-06-20T14:16:17Z (over 3 years ago)
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 by (deleted user) · 2021-06-20T04:02:45Z (over 3 years ago)
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?