[Help a n00b] Ashamed to admit this took me forever /u/Ok_Result_5325 Python Education

I just started learning 3 days ago on SoloLearn, and decided to bite off more than I can chew with this challenge:

You and three friends go to a baseball game and you offer to go to the concession stand for everyone. They each order one thing, and you do as well. Nachos and Pizza both cost $6.00. A Cheeseburger meal costs $10. Water is $4.00 and Coke is $5.00. Tax is 7%.

Task: Determine the total cost of ordering four items from the concession stand. If one of your friend’s orders something that isn’t on the menu, you will order a Coke for them instead.

Input Format: You are given a string of the four items that you’ve been asked to order that are separated by spaces.

Output Format: You will output a number of the total cost of the food and drinks.

Sample Input: ‘Pizza Cheeseburger Water Popcorn’

Sample Output: 26.75

Even with AI coding assistance, it still took me an hour to come up with this: prices = { “Nachos” : 6.00, “Pizza” : 6.00, “Cheeseburger” : 10.00, “Water”: 4.00, “Coke” : 5.00 } t=1.07 item=input() food=item.split() total=0 for item in food: if item in prices: total+=prices[item]t else: total+=prices[“Coke”]t print(round(total,2))

Anyway, I would appreciate any advice on how to make my code less clunky.

submitted by /u/Ok_Result_5325
[link] [comments]

​r/learnpython I just started learning 3 days ago on SoloLearn, and decided to bite off more than I can chew with this challenge: You and three friends go to a baseball game and you offer to go to the concession stand for everyone. They each order one thing, and you do as well. Nachos and Pizza both cost $6.00. A Cheeseburger meal costs $10. Water is $4.00 and Coke is $5.00. Tax is 7%. Task: Determine the total cost of ordering four items from the concession stand. If one of your friend’s orders something that isn’t on the menu, you will order a Coke for them instead. Input Format: You are given a string of the four items that you’ve been asked to order that are separated by spaces. Output Format: You will output a number of the total cost of the food and drinks. Sample Input: ‘Pizza Cheeseburger Water Popcorn’ Sample Output: 26.75 Even with AI coding assistance, it still took me an hour to come up with this: prices = { “Nachos” : 6.00, “Pizza” : 6.00, “Cheeseburger” : 10.00, “Water”: 4.00, “Coke” : 5.00 } t=1.07 item=input() food=item.split() total=0 for item in food: if item in prices: total+=prices[item]t else: total+=prices[“Coke”]t print(round(total,2)) Anyway, I would appreciate any advice on how to make my code less clunky. submitted by /u/Ok_Result_5325 [link] [comments] 

I just started learning 3 days ago on SoloLearn, and decided to bite off more than I can chew with this challenge:

You and three friends go to a baseball game and you offer to go to the concession stand for everyone. They each order one thing, and you do as well. Nachos and Pizza both cost $6.00. A Cheeseburger meal costs $10. Water is $4.00 and Coke is $5.00. Tax is 7%.

Task: Determine the total cost of ordering four items from the concession stand. If one of your friend’s orders something that isn’t on the menu, you will order a Coke for them instead.

Input Format: You are given a string of the four items that you’ve been asked to order that are separated by spaces.

Output Format: You will output a number of the total cost of the food and drinks.

Sample Input: ‘Pizza Cheeseburger Water Popcorn’

Sample Output: 26.75

Even with AI coding assistance, it still took me an hour to come up with this: prices = { “Nachos” : 6.00, “Pizza” : 6.00, “Cheeseburger” : 10.00, “Water”: 4.00, “Coke” : 5.00 } t=1.07 item=input() food=item.split() total=0 for item in food: if item in prices: total+=prices[item]t else: total+=prices[“Coke”]t print(round(total,2))

Anyway, I would appreciate any advice on how to make my code less clunky.

submitted by /u/Ok_Result_5325
[link] [comments] 

Leave a Reply

Your email address will not be published. Required fields are marked *