基本上,我需要使我的程序能够为我创建多个(无限的)变量,我仍然能够通过代码使用操纵,而不需要定义它们。在
我想用一个字母和一个数字作为变量名,比如a1,然后让程序创建新的变量,只需在数字上加1。因此,它会产生a1通过a30左右。我该怎么做?在
我的程序将要添加多项式,变量(或现在列出)是分开不同的单项式,因为我不知道多项式中有多少个单项式,所以我需要一种方法使数字灵活,这样我就有了一个精确的单项式空间,没有多余的,也没有更少的。在
代码如下:# Sample polynomial set to x, the real code will say x = (raw_input("Enter a Polynomial")).
x = '(5xx + 2y + 2xy)+ (4xx - 1xy)'
# Isdigit command set to 't' to make the code easier to write.
t = str.isdigit
# Defining v for later use.
v = 0
# Defining 'b' which will be the index number that the program will look at.
b = 1
# Creating 'r' to parse the input to whatever letter is next.
r = x [b]
# Defining n which will be used later to tell if