'How to add back to back zeros in python without string?
So this is the question given: Consider the two lists list1 = [11, 22, 33, 44, 55] and list2 = [66, 77, 88, 99, 00]. How can we join the two list and make it final_list = [11, 22, 33, 44, 55, 66, 77, 88, 99, 00]
I'm not asking for the answer but when I run the code below I only get one zero at the end?? I can't use a string. Code:
list1 = [11, 22, 33, 44, 55]
list2 = [66, 77, 88, 99, 00]
final_list= list1+list2
print(final_list)
Output:
[11, 22, 33, 44, 55, 66, 77, 88, 99, 0]
Solution 1:[1]
You can't do that in python, any leading 0 in an int will be removed.
You must convert your integer to an str if you want to keep the leading 0s.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | qcoumes |
