3 ms·
The most obvious way to iterate over a string character by character in Python is 'for char in string: ...'; that loop invokes str.__iter__ which will be an O(n
by MichaelSalib 14y ago
The most obvious way to iterate over a string character by character in Python is 'for char in string: ...'; that loop invokes str.__iter__ which will be an O(n) rather than O(n^2) operation.