I wrote a function that reads from a file and checks each line according to some conditions. Each line in the file contains a number. In the function itself, I'd like to add to this number and check it again so I tried the following:
str(int(l.strip())+1)) # 'l' being a line in the file
I noticed that I got some faulty results each time I cast a number with leading zeroes. (The file contains every possible 6-digit number, for example: 000012).
I think that the conversion to integer just discards the unnecessary leading zeroes, which throws off my algorithm later since the string length has changed.
Can I convert a string to an integer without losing the leading zeores?