def bill_cal():
split_amount = bill_amount_list * (1-cashback_rate) / person_split_no
print(f"each person should pay {split_amount}.")
bill_amount = input("How much is the bill? You can enter multiple bills separated by comma.\n")
bill_amount_list = bill_amount.split(",")
cashback_rate = float(input("Is there any credit card cashback on the bills? 2% = 0.02\n"))
person_split_no = int(input("How many people are splitting the bill?"))
for bill in map(float, bill_amount_list):
bill_cal()
I am trying to cast float on each item obtained from bill_amount.split(",")
, and perform the bill_cal()
function, but got below error:
How much is the bill? You can enter multiple bills separarted by comma.
100,200
Is there any credit card cashback on the bills? 2% = 0.02
.02
How many people are splitting the bill?2
Traceback (most recent call last):
File "main.py", line 10, in <module>
bill_cal()
File "main.py", line 2, in bill_cal
split_amount = bill_amount_list * (1-cashback_rate) / person_split_no
TypeError: can't multiply sequence by non-int of type 'float'