是否具有创建一维动态矩阵的功能?在python

问题描述 投票:1回答:1

你好,我是python的初学者,想指定两个动态数组..如果我输入值..它将保存在数组中当我按下键盘“ n” ..第一个数组应该被保存。然后我从第二个数组开始..如果再次按“ n”,我应该有一个表格..包括第一个和第二个数组。

你能帮我吗?

a = int(input("\ngive the values of Gas1: "))
aList = [0] * a
for i in range(len(aList)):
    aList[i] = (input('give the following value of gas 1[' + str(i) + ']: '))
    if aList[i] == 'n': 
        break
print('\n\nGas 1 has the following values :', aList)



b = int(input("\ngive the values of Gas2: "))
bList = [0] * b
for j in range(len(bList)):
    bList[j] = int(input('give the following value of gas 2[' + str(j) + ']: '))
    if bList[j] == 'n':
        break
print('\n\nGgas 2 has the following values:', bList)


print("\n\n--------------------------------------\n   The table for gas mixing\n--------------------------------------")
print('Gas1\t\t Gas2\t\t Luft')
for i in aList:
    for j in bList:
        Gassumme = int(i) + int(j)
        Prozent = 100
        x = Prozent - Gassumme
        print('', i, '%', '\t\t', j, '%', '\t\t', x, '%')
        print("--------------------------------------")
python arrays input dynamic append
1个回答
0
投票
List=[0]
while True:
    for i in range(len(List)) :
List[i] = List.append(input('schreib die erste elment'))
if List[i] == 'n':
    break
print(List)

hi Shakeel谢谢你的回答

这里是一个简单的示例..我只需要提供动态数组“ List”的值即可。如果我按“ n” ..数组“列表”将被保存并显示

© www.soinside.com 2019 - 2024. All rights reserved.