Wie fügt man mehrere Elemente in einer Zeile in Python an

Habe ich:

count = 0
i = 0
while count < len(mylist):
    if mylist[i + 1] == mylist[i + 13] and mylist[i + 2] == mylist[i + 14]:
        print mylist[i + 1], mylist[i + 2]
    newlist.append(mylist[i + 1])
    newlist.append(mylist[i + 2])
    newlist.append(mylist[i + 7])
    newlist.append(mylist[i + 8])
    newlist.append(mylist[i + 9])
    newlist.append(mylist[i + 10])
    newlist.append(mylist[i + 13])
    newlist.append(mylist[i + 14])
    newlist.append(mylist[i + 19])
    newlist.append(mylist[i + 20])
    newlist.append(mylist[i + 21])
    newlist.append(mylist[i + 22])
    count = count + 1
    i = i + 12

Ich wollte die newlist.append() Aussagen in ein paar Erklärungen.

Kommentar zu dem Problem - Öffnen
Gut ist es natürlich nicht das gleiche, wenn Sie unterschiedliche Ergebnisse erhalten. Kommentarautor: JJJ
Das ist ungültige syntax. Kommentarautor: TerryA
Vorausgesetzt, Ihre Objekte gemeint sind, zu Listen, die Ihr code ist nicht gültig Python, wie Sie mit Hilfe von [] statt (). Bitte postet wirklich funktionierende code. Kommentarautor: BrenBarn

InformationsquelleAutor der Frage whatever | 2013-05-18

Schreibe einen Kommentar