I need to create a program which only has functions in it. No main code (!). We need to create the largest possible number from a list. so in [50,9,2,1] the outcome must be 95021.
I've tried using this code:
def max_out(l):
new_num = ""
if(len(l) == 0):
print("")
exit()
numb = []
for numbers in l:
numbers = str(numbers)
nummer = numbers[0:1]
numb.append(nummer)
t = len(numb)
while t > 0:
t = len(numb)
mx = numb.index(max(numb))
new_num += str(l[mx])
numb.remove(mx)
l.remove(mx)
return new_num
print(max_out([50,9,2,1]))
but it keeps giving the error:
numb.remove(mx) ValueError: list.remove(x): x not in list
l.remove(mx) ValueError: list.remove(x): x not in list
can someone please help me?