我需要 20 个空列表,其中包含从 a 到 t 的字母。我现在的代码是:
list_a = []
list_b = []
list_c = []
...
创造了我这个:
list_a[]
list_b[]
list_c[]
...
我可以用一个简单的for循环来做到这一点吗?这就是我现在所拥有的。我可以将字母从 a 循环到 t 并打印出来
for i in range(ord('a'), ord('t') +1):
print i
输出:
a
b
c
d
e
...
等等...
我写的那个脚本需要它。我有 2 个空列表用于测试。它工作正常。但现在我需要玩 20 个列表
from os import system
list_a = []
list_b = []
list_c = [1, 2, 3, 4, 5]
while True:
system("clear")
print "\nList A ---> ", list_a
print "List B ---> ", list_b
print "List C ---> ", list_c
item = input ("\n?> ")
place = [list_a, list_b, list_c]
place_name = ["List A", "List B", "List C"]
for i ,a in zip(place, place_name):
if item in i:
print "\nItem", item, "--->", a
print "\n\n1) List A"
print "2) List B"
print "3) List C\n"
target = input("move to ---> ")
target = target - 1
target = place[target]
i.remove(item)
target.append(item)
print "\nItem moved"
break
raw_input()