
您可以一站式完成所有 *** 作
how_many = int(input("How many terms are in the equation?"))terms = {}for i in range(how_many): var = int(input("Enter the coefficient for variable")) terms["T{}".format(i)] = var然后您可以使用
print( terms['T0'] )
但是使用列表而不是字典可能更好
how_many = int(input("How many terms are in the equation?"))terms = [] # empty listfor i in range(how_many): var = int(input("Enter the coefficient for variable")) terms.append(var)然后您可以使用
print( terms[0] )
甚至(获得前三个学期)
print( terms[0:3] )
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)