我试图弄清楚这个程序将打印什么,但我对函数实际打印的内容有疑问
def main():
d = {1 : "car",
2 : "house",
3 : "boat",
4 : "dog",
5 : "kitchen"}
L = list(d.keys()) #i know that here a list L is created with values [1,2,3,4,5]
i = 0
while i < len(L):# while i is less than 5 because of length of list L
k = L[i] # k = l[0] so k == 1
if k < 3 : # if 1 < 3
d[ d[k] ] = "zebra" d[ d[1] ] = #zebra so it adds zebra to the dictionary key 1 #right?
i += 1 # here just i += 1 simple enough and while loop continues
# loop continues and adds zebra to dictionary key 2 and stops
for k in d :
print(k, d[k]) #This is were im having trouble understanding how everything is printed
main()