43 lines
693 B
Python
43 lines
693 B
Python
|
#5_3
|
||
|
list1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
||
|
print("start list", list1)
|
||
|
|
||
|
a = list1[9]
|
||
|
b = list1[8]
|
||
|
c = list1[7]
|
||
|
|
||
|
list1 = [c] + [b] + [a] + list1
|
||
|
list1.pop(-1)
|
||
|
list1.pop(-1)
|
||
|
list1.pop(-1)
|
||
|
|
||
|
print("new list", list1)
|
||
|
print()
|
||
|
print()
|
||
|
|
||
|
#5_4
|
||
|
#a
|
||
|
word = "DONAUDAMPFSCHIFFAHRTSGESELLSCHAFTSSTEWARDESS"
|
||
|
letters = list(word)
|
||
|
print(letters)
|
||
|
print("length:", len(letters))
|
||
|
|
||
|
#b
|
||
|
letters_once = []
|
||
|
for element in letters:
|
||
|
if element not in letters_once:
|
||
|
letters_once.append(element)
|
||
|
|
||
|
print(letters_once)
|
||
|
print("length new:", len(letters_once))
|
||
|
|
||
|
print()
|
||
|
print()
|
||
|
|
||
|
#5_5
|
||
|
def sort(list2):
|
||
|
list2.sort(key = lambda x: x[1])
|
||
|
return list2
|
||
|
|
||
|
list2 = [[1, 2, 3], [2, 1, 3], [4, 0, 1]]
|
||
|
print(sort(list2))
|