Elemente in eine andere Liste verschieben
Verfasst: Donnerstag 11. Juni 2020, 16:22
Hallo,
ich möchte eigentlich nichts kompliziertes machen, stelle mich aber aktuell einfach etwas an.
Ausgangslage:
Ziel:
Dazu habe ich folgendes ausproboiert:
Leider kommt es zu folgendem Ergebnis:
Es fehlt also die 'server-d9010.subdomain.domain.de' in der host_list_subdomain und wird in der host_list außer acht gelassen.
Was mach ich hier falsch?
VG niesel
ich möchte eigentlich nichts kompliziertes machen, stelle mich aber aktuell einfach etwas an.
Ausgangslage:
Code: Alles auswählen
host_list_subdomain=[]
host_list=['server-d9009.subdomain.domain.de', 'server-d9010.subdomain.domain.de', 'server-a5001.subdomain.domain.de', 'server-ran001.domain.subdomain.com', 'server-jen001.domain.subdomain.com', 'server-backup-a0001.domain.subdomain.com', 'server-zen001.domain.subdomain.com', 'server-zen002.domain.subdomain.com']
Code: Alles auswählen
host_list_subdomain=['server-d9009.subdomain.domain.de', 'server-d9010.subdomain.domain.de']
host_list=['server-a5001.subdomain.domain.de', 'server-ran001.domain.subdomain.com', 'server-jen001.domain.subdomain.com', 'server-backup-a0001.domain.subdomain.com', 'server-zen001.domain.subdomain.com', 'server-zen002.domain.subdomain.com']
Code: Alles auswählen
host_list_subdomain=[]
host_list=['server-d9009.subdomain.domain.de', 'server-d9010.subdomain.domain.de', 'server-a5001.subdomain.domain.de', 'server-ran001.domain.subdomain.com', 'server-jen001.domain.subdomain.com', 'server-backup-a0001.domain.subdomain.com', 'server-zen001.domain.subdomain.com', 'server-zen002.domain.subdomain.com']
for host in host_list:
if "d90" in host:
host_list_subdomain.insert(0, host_list.pop(host_list.index(host)))
print(host_list_subdomain)
print(host_list)
Code: Alles auswählen
host_list_subdomain=['server-d9009.subdomain.domain.de']
host_list=['server-d9010.subdomain.domain.de', 'server-a5001.subdomain.domain.de', 'server-ran001.domain.subdomain.com', 'server-jen001.domain.subdomain.com', 'server-backup-a0001.domain.subdomain.com', 'server-zen001.domain.subdomain.com', 'server-zen002.domain.subdomain.com']
Was mach ich hier falsch?
VG niesel