我想做一个程序,将while循环中的数据添加到列表中,并计算数据。然而,当我使用.append时,它什么也不返回。
structure = input("Equation: ")
print("RANGE")
upper_lim = int(input("Upper limit: "))
value_i = int(input("The value of 'i': "))
nth = [""]
substitution = [""]
while value_i <= upper_lim and "i" in structure and "+" not in structure:
substitution = print(structure.replace("i", "(" + str(value_i) + ")"))
value_i += 1
nth.append(substitution)
while value_i <= upper_lim and "i" in structure:
substitution = print(structure.replace("i", "(" + str(value_i) + ")"))
value_i += 1
nth.append(substitution)
print(nth)
结果是:
['', None, None, None]
而不是像这样:
[numbers,numbers,numbersr]
1条答案
按热度按时间8i9zcol21#
Print()显示项目,但返回None,保存在替代变量中