def get_count(n):
i = 1
while n != 1:
(n, i) = (3*n+1 if n%2 else n/2, i + 1)
return(i)
nlist=[]
a = int(input("collatz trajecory length of:"))
for x in range(1,a+1):
nlist.insert(x, get_count(x)+"hello") #"need to add the get_count to the "x" valure for example= 20_9
#where 20 is the length of the trajectory and 9 is the number we're calculating the trajectory of.
#the error has to do with not being able to convert the variuble, whitch is and integer function, to a string.
#if i sucseed, i also get an error where i cant combine the getcount variuble and the string number variuble.
inlist.sort(key=lambda x: (int(x.split(None, 1)[0]) if x[:1].isdigit() else 999, x)) #another wierd error
#i dont understant about bytes.
print(nlist)
I expected it to output a list with the terms (example) [<trajectory_length>_,3_2,8_5] i want it to sort by TRAJECTORY length, lowest to highest. the number to be calculated is NOT in order, just an indicator of whet number was tested.