使用输入从数组中分配2个变量?

时间:2016-03-03 23:48:05

标签: python arrays variables

尝试从数组中选择vdiv和hdiv?

divOptions = [['|', '-'], ['4', '2'], ['v', 'h']]
divChoice = input('1 = |, - \n2 = 4, 2 \n3 = v, h \nPlease choose a number: ')
divInt = divOptions[divChoice - 1]
vdiv, hdiv = divInt

1 个答案:

答案 0 :(得分:0)

你想要的是

vdiv, hdiv = divInt[0], divInt[1]

并将输入转换为整数:

divChoice = int(input(...))