Python 使用输入从数组中分配2个变量?
正在尝试从阵列中选择vdiv和hdivPython 使用输入从数组中分配2个变量?,python,arrays,variables,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 你想要的是 vdiv, hdiv = divInt[0], divInt[1] 并将输入
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
你想要的是
vdiv, hdiv = divInt[0], divInt[1]
并将输入转换为整数:
divChoice = int(input(...))
您需要将
divChoice
转换为整数。