I made a quick budgeting program to determine how long it would take to buy something, and I ran into a problem. Whenever I try and run it, the one-time sales items don't get added to the balance. My code is as follows:
graphicsCard = 50
amdCpu = 80
itelCpu = 99
ram = 140
guitar = 199
case = 99
balance = 21
if (input('Has the graphics card been sold yet?').lower == "yes"):
balance += graphicsCard
if (input('Has the AMD cpu been sold yet?').lower == "yes"):
balance += amdCpu
if (input('Has the intel CPU been sold yet?').lower == "yes"):
balance += intelCpu
if (input('Has the RAM been sold yet?').lower == "yes"):
balance += ram
if (input('Has the Guitar been sold yet?').lower == "yes"):
balance += guitar
if (input('Has the Case been sold yet?').lower == "yes"):
balance += case
I added an else statement to after the first if, to detect if it was reading my 'yes' answer properly, and it was not.
Aucun commentaire:
Enregistrer un commentaire