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

Time:05-01

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

CodePudding user response:

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)
  • Related