0

Help ! Python

Can someone tell me what is wrong in this code output = 0 def cost (purchase_price, commissions, taxes): for numbers in cost: output+=number print (output) cost(50,1,3)

22nd Apr 2020, 9:08 PM
kirti
6 Respostas
+ 1
I think you dont define cost that you used in line 3 and in for loop you used numbers but in line 4 you write number
22nd Apr 2020, 9:28 PM
HASH
HASH - avatar
+ 1
🤔 def cost(purchase_price, commissions, taxes): print(purchase_price + commissions + taxes) cost(50,1,3)
22nd Apr 2020, 9:36 PM
Solo
Solo - avatar
+ 1
If you don't want to use addition sign you can do something like this def cost(*args): return sum(args) output = cost(50,1,3,125,223,3323....) print(output) it will work as long as you will be passing numbers
23rd Apr 2020, 7:58 AM
Piotr Szajer
Piotr Szajer - avatar
0
cost is your function name, not iterable in for loop so you can't use there in loop... What you actually trying by this code.. If you Mention that purpose also, that's helps you to get your correct code..
22nd Apr 2020, 9:38 PM
Jayakrishna 🇮🇳
0
I did not want to use addition sign again and again.
23rd Apr 2020, 2:41 AM
kirti
0
Thanks for all replies
23rd Apr 2020, 2:42 AM
kirti