I'm trying to make a program that can work out a mathematical ratio problem and then take the square root of the answer. To achieve the multiplication part i'm trying to make empty lists to which i add the numbers the user enters to define the ratio, then multiplying the list elements with each other. However, when i tried to run the program, this is what i got:
Error:first set: 8
Traceback (most recent call last):
File "C:/root to file...", line 13, in <module>
data_procesing()
File "C:/root to file...", line 9, in data_procesing()
a = parameters[0] * parameters[1]
IndexError: list index out of range
Process finished with exit code 1
this is the program: def data_procesing(): while True: first_set = raw_input('first_set: ') for i in xrange(1, 2): parameters = [] parameters.append(first_set) a = parameters[0] * parameters[1] print a data_procesing()First i had the parameters = [] loop outside the function so i thought this might be a scope problem, so i put it inside the for loop, however, that didn't work either, Can anybody please tell me what i'm doing wrong? is it perhaps impossible to multiply list elements like i did?