Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
174 changes: 0 additions & 174 deletions .gitignore

This file was deleted.

6 changes: 6 additions & 0 deletions 06/tasks/task_20_second_largest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,10 @@ def second_largest(lst: list[int]) -> int:
"""
Vrátí druhé největší číslo v seznamu.
"""
lst = sorted(lst, reverse=True)
for finder in lst:
if finder < lst[0]:
numero = finder
break
Comment on lines +8 to +11
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Když už ten seznam řadíš, tak už nepotřebuješ žádný for ani if.

Copy link
Contributor Author

@Klikasoft Klikasoft Apr 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ten for a if jsem tam dal pro pripad, ze by seznam obsahoval duplicity, mel jsem najít druhe nejvetsi cislo, sorted by mi je jen seradil, ale v pripade [10,12,12,12,11,11] bych druhe nejvetsi nenasel, pouhým lst[1] ale uznávám, že se to jistě dalo napsat i líp :)


return numero