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.

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

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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)


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x