下面代码运行,屏幕输出的结果是:
lists = ["a", "b", "c", "d"]
for i in range(len(lists)):
lists[0], lists[1:] = lists[-1], lists[:-1]
print(lists)
A. a b c d
B. d c b a
C. b a d c
D. 程序运行错误
下面代码运行,屏幕输出的结果是:
lists = ["a", "b", "c", "d"]
for i in range(len(lists)):
lists[0], lists[1:] = lists[-1], lists[:-1]
print(lists)
A. a b c d
B. d c b a
C. b a d c
D. 程序运行错误
答案是A,循环了四次,每次都是最后一个值替换为第一个值