diff --git a/s1_a53_6.py b/s1_a53_6.py new file mode 100644 index 0000000..a95f969 --- /dev/null +++ b/s1_a53_6.py @@ -0,0 +1,51 @@ +def move_list_elemts(): + list1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] + list2 = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"] + counter = 0 + while counter < 7: + list1.append(list1.pop(0)) + counter = counter + 1 + + print(list1) + + +def list_remove_duplicates(): + word = "Donaudampfschiffahrtsgesellschaftsstewardess" + word_list = list(word) + print(len(word_list)) + + result_list = [] + + for letter in word: + if letter not in result_list: + result_list.append(letter) + + print(result_list) + print(len(result_list)) + + +def sort_list(): + list1 = [[1, 2, 3], [2, 1, 3], [4, 0, 1]] + list1.sort(key=lambda x: x[1]) + print(list1) + + +def fake_switch(): + tier_name = 'Hund' + tier_sound = {'Hund': 'wuff', 'Katze': "miau"} + print(tier_sound[tier_name]) + + +def main(): + print("Aufgabe 3:") + move_list_elemts() + print("Aufgabe 4:") + list_remove_duplicates() + print("Aufgabe 5:") + sort_list() + print("Aufgabe 6:") + fake_switch() + + +if __name__ == '__main__': + main() diff --git a/s1_a61_2.py b/s1_a61_2.py new file mode 100644 index 0000000..ed18801 --- /dev/null +++ b/s1_a61_2.py @@ -0,0 +1,18 @@ +def space_to_minus(text): + split_text = text.split(" ") + return "-".join(split_text) + + +def reverse_text_till_komma(text): + text_list = text.split(",") + text_list[0] = text_list[0][::-1] + return ",".join(text_list) + + +def main(): + print(space_to_minus("This is a test")) + print(reverse_text_till_komma("Hallo,Welt")) + + +if __name__ == "__main__": + main()