diff --git a/01_verdoppeln.py b/01_verdoppeln.py index 3f1742f..e6d3acb 100644 --- a/01_verdoppeln.py +++ b/01_verdoppeln.py @@ -1,7 +1,3 @@ numbers = [1, 2, 3, 4, 5] - -# Verdopplung aller Zahlen mittels map -result = list(map(lambda x: x * 2, numbers)) - -print("Ergebnis:", result) -#assert result == [2, 4, 6, 8, 10] \ No newline at end of file +result = list(map(lambda x: x * 2, [1, 2, 3, 4, 5])) +print(result) \ No newline at end of file diff --git a/02_trump_style.py b/02_trump_style.py index 87776af..db660ea 100644 --- a/02_trump_style.py +++ b/02_trump_style.py @@ -1,7 +1,5 @@ words = ["huge", "great", "tremendous", "fake news"] - # Strings in Großbuchstaben umwandeln und "!" anhängen result = list(map(lambda word: word.upper() + "!", words)) - print("Ergebnis:", result) #assert result == ["HUGE!", "GREAT!", "TREMENDOUS!", "FAKE NEWS!"] \ No newline at end of file diff --git a/03_gerade_zahlen.py b/03_gerade_zahlen.py index 2638ad7..2bba0f6 100644 --- a/03_gerade_zahlen.py +++ b/03_gerade_zahlen.py @@ -1,7 +1,4 @@ numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] - # Nur gerade Zahlen (x % 2 == 0) herausfiltern result = list(filter(lambda x: x % 2 == 0, numbers)) - print("Ergebnis:", result) -assert result == [2, 4, 6, 8, 10] \ No newline at end of file diff --git a/04_k_laenge.py b/04_k_laenge.py index 3cc6c9a..55fc405 100644 --- a/04_k_laenge.py +++ b/04_k_laenge.py @@ -2,6 +2,6 @@ words = ["Kuchen", "Katze", "Apfel", "Kaffee", "Baum", "Kino"] # Einzeiler kombiniert filter, map und sum total_length = sum(map(len, filter(lambda w: w.lower().startswith('k'), words))) - print("Gesamtlänge aller K-Wörter:", total_length) -assert total_length == 6 + 5 + 6 + 4 # Kuchen (6) + Katze (5) + Kaffee (6) + Kino (4) = 21 \ No newline at end of file + +#assert total_length == 6 + 5 + 6 + 4 # Kuchen (6) + Katze (5) + Kaffee (6) + Kino (4) = 21 \ No newline at end of file