Python program bug | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Python program bug

https://code.sololearn.com/c4NfAJIfFm9G/#py Iv'e built a program which works like a bank. I'm having a problem with the transaction function. For some reason is saves two strings of both transactions. i commented the whole code so you can understand what anything does. To get the to the problem you must create two accounts, then try to transfer funds from one account to the other. and then check the transactions list.

6th May 2018, 7:17 PM
Tomer Sim
Tomer Sim - avatar
1 Answer
0
You created many class attributes instead of instance attributes. Doing so, for example, the variable "__transcations" in class account is created the first time code is executed and changed by any instance. Just move these variables to "def __init__" and instance them by adding 'self.' in front of them. https://code.sololearn.com/cXRjmFm285hU/?ref=app
7th May 2018, 8:56 PM
Stéphane Dumas
Stéphane Dumas - avatar