Skip to content

Instantly share code, notes, and snippets.

@a1exDi
Created May 24, 2022 10:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save a1exDi/c0ff11f93381d28086c526395de4666e to your computer and use it in GitHub Desktop.
Save a1exDi/c0ff11f93381d28086c526395de4666e to your computer and use it in GitHub Desktop.
Найти слово с наибольшим количеством символов
x = ["python", "java", "c++", "c#", "javascript"]
word1 = None
max_length = 0
for i in x:
if len(i) > max_length:
max_length = len(i)
word1 = i
print(word1)
# или так
x = ["python", "java", "c++", "c#", "javascript"]
word2 = max(x, key=len)
print(word2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment