Merge remote-tracking branch 'origin/main'
commit
0a03f947a8
|
@ -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()
|
|
@ -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()
|
Loading…
Reference in New Issue