Skip to content
Advertisement

I have written this function to get the size of a string, can it be optimized?

I don’t want to use python functions to calculate but I want to implement a function myself. The problem comes when the chain is very long. The program starts to take about 5 minutes.

enter image description here

Advertisement

Answer

Why don’t you use len()? I think what you’re trying to do is just len('holaaaaaa') and I don’t think that it can be more optimized than that. if you want to implement the function your self then you cand do:

def StringLenght(string):
    return len(string)
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement