-1
def get(i, x):
i = 0
numbers = []
while i < x:
print ('At the top i is %d' % (i))
numbers.append(i)
i = i + 1
print ("Numbers now: "), numbers
print ("At the bottom i is %d" % (i))
print ("The numbers: ")
for num in numbers:
print (num)
get(1,6)
Also, wenn ich die Funktion aufrufen, dies ist das Ergebnis:Liste Anfügen funktioniert nicht
At the top i is 0
Numbers now:
At the bottom i is 1
At the top i is 1
Numbers now:
At the bottom i is 2
At the top i is 2
Numbers now:
At the bottom i is 3
At the top i is 3
Numbers now:
At the bottom i is 4
At the top i is 4
Numbers now:
At the bottom i is 5
At the top i is 5
Numbers now:
At the bottom i is 6
The numbers:
0
1
2
3
4
5
Warum "Numbers now: "
wird nichts angezeigt? Ist etwas falsch mit print
Anweisung, die append
Funktion oder was? Ich bin hier verloren, schätze jede Hilfe.
Da es in der schließenden Klammer sein sollte;) –
Dank Mann, nebenbei gesagt, warum ich werde immer für downvoted? – Dan
Ich bin kein Downvoter, aber vielleicht weil Python 3.x 'print' eine ** Funktion ** ist, keine Anweisung und kann daher nur Dinge ausgeben, die als Argumente übergeben werden ... oder vielleicht liegt es daran scheint, als hättest du dieses Problem selbst herausfinden können. – martineau