I Created 2 Python files 1 class and 1 Main and wanted to compare 2 Instances to see who had the most value
class Conta:
def __init__(self, titular, numero, quantidade):
self.titular = titular
self.numero = numero
self.quantidade = quantidade
def info(self):
print(f"The Account {self.numero} with the titular {self.titular} has {self.quantidade}")
from Conta import Conta
Conta1 = Conta("Miguel", "987654", "300")
Conta2 = Conta("Fernando", "123456", "600")
Conta1.info()
Conta2.info()
valor = Conta1.quantidade - Conta2.quantidade
if Conta1.quantidade <= Conta2.quantidade:
print(f"O {Conta1.titular} has more {valor} then {Conta2.titular}")
elif Conta2.quantidade <= Conta1.quantidade:
print(f"O {Conta2.titular} has more {valor} then {Conta1.titular}")
elif Conta1.quantidade == Conta2.quantidade:
print(f"O {Conta1.titular} has same value then {Conta2.titular}")
But cant seem to get a valor for the difference between the 2 instances
New contributor
Fire_Elite YT is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.