|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
print('''----------猜数字小游戏----------
请在1到63内选一个数字记在心里
下面看看你选的数字在下列6个列表里哪个出现过
并把出现你想的数字列表序号输入
例如5在表格1表格3中出现,则输入"13"''')
L1 = list(range(1,64,2))
A = list(range(2,64,4))
B = list(range(3,65,4))
C = list(range(4,61,8))
D = list(range(5,62,8))
E = list(range(6,63,8))
F = list(range(7,64,8))
a = list(range(8,16))
b = list(range(24,32))
c = list(range(40,48))
d = list(range(56,64))
a1 = list(range(16,32))
b1 = list(range(48,64))
L1 = list(range(1,64,2))
L2 = A + B
L3 = C + D + E + F
L4 = a + b + c + d
L5 = a1 + b1
L6 = list(range(32,64))
L1.sort()
L2.sort()
L3.sort()
L4.sort()
L5.sort()
L6.sort()
print('\n','列表1',L1,'\n'*3)
print('列表2',L2,'\n'*3)
print('列表3',L3,'\n'*3)
print('列表4',L4,'\n'*3)
print('列表5',L5,'\n'*3)
print('列表6',L6,'\n')
SN = str(input('请输入列表序列:'))
T = len(SN)
SN = list(SN)
answer = 0
while T != 0:
a = SN.pop()
if a == 1:
answer = answer + 1
elif a == 2:
answer = answer + 2
elif a == 3:
answer = answer + 4
elif a == 4:
answer = answer + 8
elif a == 5:
answer = answer + 16
elif a == 6:
answer = answer + 32
T = T -1
print("你心里想的数字是",answer)
不知道为什么answer一直为0
改动如下, while T != 0:
a = SN.pop()
if a == '1':
answer = answer + 1
elif a == '2':
answer = answer + 2
elif a == '3':
answer = answer + 4
elif a == '4':
answer = answer + 8
elif a == '5':
answer = answer + 16
elif a == '6':
answer = answer + 32
T = T -1
print("你心里想的数字是",answer)
|
|