Skip to content

flatten the list#58

Merged
ZelenyMartin merged 1 commit intoPyLadiesCZ-Brno:mainfrom
Dragca:dk-28-flatten-list
Apr 9, 2025
Merged

flatten the list#58
ZelenyMartin merged 1 commit intoPyLadiesCZ-Brno:mainfrom
Dragca:dk-28-flatten-list

Conversation

@Dragca
Copy link
Contributor

@Dragca Dragca commented Apr 7, 2025

zadání mi přijde identické s taskem 10
šlo by to napsat i takto:

flatten = []
for sublist in nested:
for digit in sublist:
flatten.append(digit)

return flatten 

ale list comprehension mi přijde úhlednější, může takto být?

@Dragca Dragca force-pushed the dk-28-flatten-list branch from c0aad13 to 8e87368 Compare April 7, 2025 11:24
Copy link
Contributor

@ZelenyMartin ZelenyMartin left a comment

Choose a reason for hiding this comment

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

Ano, je to stejny ukol jako 10. ChatGPT se opakovalo. Urcite je vhodnejsi pouzit list comprehension.

Pokud chces bonusove rozsireni, tak se muzes inspirovat timto ukolem: https://github.com/PyLadiesCZ-Brno/python-knihovny/blob/main/06/test_36_sum_nested_list.py a udelat zplosteni libovolne zanorenych seznamu. (36 uz je udelana, tak se nedivej na reseni).

Toto zamerguju, tak to rozsireni muzes poslat jako dalsi PR i s prislusnym rozsirenim testu.

@ZelenyMartin ZelenyMartin merged commit 6cc7c85 into PyLadiesCZ-Brno:main Apr 9, 2025
3 checks passed
@Dragca Dragca deleted the dk-28-flatten-list branch April 23, 2025 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants