So I want to pass two lists into my function. The aim of my program is to solve a system of three linear equations using the Gauss Jordan Method.
import sys
from tkinter import *
def elim(x,list_a,list_b):
r=-list_b[x]/list_a[x]
for i in range(x-1,len(list_b)+1):
list_b[i]=list_b[i]+r*list_a[i]
return list_b
def mhello():
ma1=a1.get()
ma2=a2.get()
ma3=a3.get()
ma4=a4.get()
mb1=b1.get()
mb2=b2.get()
mb3=b3.get()
mb4=b4.get()
mc1=c1.get()
mc2=c2.get()
mc3=c3.get()
mc4=c4.get()
lista=(int(ma1),int(ma2),int(ma3),int(ma4))
listb=(int(mb1),int(mb2),int(mb3),int(mb4))
listc=(int(mc1),int(mc2),int(mc3),int(mc4))
elim(1,lista,listb)
print(listb)
when I do enter the values, I get the following error:
File "C:/Users/madhuri/Desktop/gauss.py", line 29, in mhello
elim(1,lista,listb)
File "C:/Users/madhuri/Desktop/gauss.py", line 6, in elim
list_b[i]=list_b[i]+r*list_a[i]
TypeError: 'tuple' object does not support item assignment
What am I doing incorrectly? How can I pass a list to a fucntion as an argument? How can I return a list?