48 lines
778 B
Python
48 lines
778 B
Python
print("Aufgabe 3:")
|
|
|
|
liste = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
|
|
|
print("Liste: ", liste)
|
|
|
|
a = liste[-1]
|
|
b = liste[-2]
|
|
c = liste[-3]
|
|
|
|
liste = [a] + liste
|
|
liste = [b] + liste
|
|
liste = [c] + liste
|
|
|
|
for x in range(3):
|
|
liste.pop(-1)
|
|
|
|
print("Liste neu:", liste)
|
|
|
|
print()
|
|
print("Aufgabe 4:")
|
|
|
|
strings="Donaudampfschiffahrtsgesellschaftsstewardess"
|
|
x=list(strings)
|
|
|
|
resultantList = []
|
|
|
|
print(x)
|
|
|
|
print("Länge der Liste:", len(x))
|
|
|
|
for element in strings:
|
|
if element not in resultantList:
|
|
resultantList.append(element)
|
|
|
|
print(resultantList)
|
|
|
|
print("Länge der Liste ohne Duplikate:", len(resultantList))
|
|
|
|
print()
|
|
print("Aufgabe 5:")
|
|
|
|
def sort(sub_li):
|
|
sub_li.sort(key = lambda x: x[1])
|
|
return sub_li
|
|
|
|
sub_li =[[1, 2, 3], [2, 1, 3], [4, 0, 1]]
|
|
print(sort(sub_li)) |