Joining elements in a list without the join command
You could just convert each element to a string
, add them, and then convert back to an int
:
def lists(list1):
answer=''
for number in list1:
answer+=str(number)
print(int(answer))
lists([12,4,15,11])
>>>
1241511
If you just want to print the number rather than return
an actual int
:
>>> a = [12,4,15,11]
>>> print(*a, sep='')
1241511