Our while loop also skips leading 0's like this:
ex: 048
result = 0
result = result * 10 + whatever s[i] points to
0 * 10 + 0 = 0
0 * 10 + 4 = 4
4 * 10 + 8 = 48
result = 48
On this page of the site you can watch the video online LeetCode 8. String to Integer (atoi) (Python) with a duration of hours minute second in good quality, which was uploaded by the user gcmaidana 06 June 2025, share the link with friends and acquaintances, this video has already been watched 90 times on youtube and it was liked by 3 viewers. Enjoy your viewing!