What’s wrong with my code? Python | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

What’s wrong with my code? Python

Please help me, what’s wrong with line 5? print("Welcome to the tip calculator!") bill = float(input("What was the total bill?

quot;)) tip = int(input("How much tip would you like to give? 10, 12, or 15? ")) people = int((input("How many people to split the bill? ")) bill_with_tip = tip / 100 * bill + bill print(bill_with_tip) bill_per_person = bill_with_tip / people final_amount = round(bill_per_person, 2) final_amount = "{:.2f}".format(bill_per_person) print(f"Each person should pay: {final_amount}")

25th Feb 2022, 9:05 AM
Lilit Harutyunyan
Lilit Harutyunyan - avatar
7 ответов
+ 4
Too many ( at the line with people Should be people =int(input("How many people to split the bill?"))
25th Feb 2022, 9:15 AM
HungryTradie
HungryTradie - avatar
+ 3
Sometimes it says line ### but your error is on the line earlier. When responding to errors, you have to check & fix the first error before trying to fix errors in later lines. In this case, your line 4 had too many opening parentheses, causing the interpreter to think line 5 was still part of line 4.
25th Feb 2022, 9:18 AM
HungryTradie
HungryTradie - avatar
+ 2
Lilit Harutyunyan HungryTradie has hit the nail on the head, too many ( in the line of the variable people print("Welcome to the tip calculator!") bill = float(input()) # bill total tip = int(input()) /100 # tip percentage people = int(input()) # splitbill num bill_with_tip = bill * tip + bill print(bill_with_tip) bill_per_person = bill_with_tip / people final_amount = round(bill_per_person, 2) final_amount = "{:.2f}".format(bill_per_person) print(f"Each person should pay: {final_amount}")
25th Feb 2022, 9:24 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 2
Timz2 laugh tip percent is an undeclared variable, which is also not created validly
6th Nov 2023, 12:02 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 1
I have a SyntaxError with line 5(((
25th Feb 2022, 9:06 AM
Lilit Harutyunyan
Lilit Harutyunyan - avatar
+ 1
Thanks you all HungryTradie you are right-the problem was with unnecessary parenthes in the line 4
25th Feb 2022, 9:23 AM
Lilit Harutyunyan
Lilit Harutyunyan - avatar
0
Hello everyone, please help out here, what's wrong with my line 3, it brings out a syntx error bill = float(input("enter bill")) tip = int(input("tip percent ")) total_bill = (tip percent + 100) * bill/100 total = round(total_bill, 2) print(total_bill)
5th Nov 2023, 9:44 AM
Timz2 laugh
Timz2 laugh - avatar