Best way to find the longest String in Python!

preview_player
Показать описание
Learn the best way to find the longest String in a List in Python

📓 ML Notebooks available on Patreon:

If you enjoyed this video, please subscribe to the channel:

~~~~~~~~~~~~~~~ CONNECT ~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~ SUPPORT ME ~~~~~~~~~~~~~~

#Python #Shorts
Рекомендации по теме
Комментарии
Автор

Whenever I watch a video of you, I wish if somehow I could steal all the knowledge you have. Thanks for all these videos.

racecarjonny
Автор

strings = ["I", "like", "Python"]

longest_string = max(strings, key=len)

print("The longest string is:", longest_string)


This will be the simplest method to find longest string.

codexplainer
Автор

When someone says "best way" or "always do this" or "never do that", I immideately know they have ko idea what they are talking about

Eknoma
Автор

sorted_l = sorted(l, key=lambda string: len(string))
print(sorted_l[-1])

malayagr
Автор

Nice tip, never noticed that the max function can take a list as argument, not to mention the keyword arguments shown!

victorsgbaptista
Автор

yea, but schools want you to think about this algorithm, not using a built in function

antxnioo
Автор

Thanks for sharing. Short but nice video

pangjianghan
Автор

I love when these pop up on my timeline

westsidecourtesy
Автор

key=len in max is very handy in lots of list algorithms

pattmehta
Автор

Sorry for the late comment, but this is just a way to compress several lines of code into one, correct?

Does this actually impact the complexity of this problem or does it stay as O(n^2)?
Thank you in advance.

kekw
Автор

Your videos are more informative! Can you please explain the following part in your way (stack overflow question)

Why is in so fast in Python 3?

ragubooks
Автор

If it have three value of same length it's retrieving only first value

lakshminarayanan
Автор

I have to confess that I didn't know this trick until last week

rondamon
Автор

I am a beginner. What are we doing when we give key=len inside max?

NEERAJ_G
Автор

hey what theme are you using? i like it lol.

tiiibo
Автор

Nice content. How to make app that scrape data from more than one site with specific keywords and then get notifications when new post from that sites appears and then show it that data on website

htcsaj
Автор

I’m still confused as to the first example of:
MAX_Length = 0

But aside from that great vid as always

totallynotampmdenjoyer
Автор

this will works only 4 strings what about integers .ex. 200 and 00200

parshuram
Автор

Why is the len function written without () ? I don't know such syntax

liri
Автор

how much is your "fancy" way slower/faster than the normal one?

thegoose
visit shbcf.ru