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)
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
+ 1
🤔
def cost(purchase_price, commissions, taxes):
print(purchase_price + commissions + taxes)
cost(50,1,3)
+ 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
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..
0
I did not want to use addition sign again and again.
0
Thanks for all replies