52 lines
1.0 KiB
Python
52 lines
1.0 KiB
Python
|
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()
|