So in summary (for lazy to read like me), what is the issue? Doesn't work as intended or throws exception? What is the error?
evstevemd
Senior Poster
3,713 posts since Jun 2007
Reputation Points: 462
Solved Threads: 392
Shorten the list and add a temporary print for testing. See what that will do for you:
# shorten list for test
a = range(1, 10)
b = []
d = 0
for n in a:
while n != 1:
if n % 2 == 0:
b.append(n)
n = n/2
elif n % 2 != 0:
b.append(n)
n = n*3 + 1
else: b.append(n)
print b, d, len(b) # test
if len(b) > d:
d = len(b)
b = []
Ene Uran
Posting Virtuoso
1,722 posts since Aug 2005
Reputation Points: 625
Solved Threads: 212