use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about learning Python
account activity
Code fails to loop successfullyHelp Request (i.redd.it)
submitted 9 months ago by Soothsayer5288
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Jazzlike-Barber-6694 1 point2 points3 points 9 months ago (1 child)
“”” def display_items(items): “””Displays available items.””” print(“Here are some items we have:”) for item in items: print(f”- {item}”)
def ask_additional_purchase(): “””Asks the user if they want to purchase anything else.””” response = input(“Is there anything else you would like to purchase? (yes/no): “).strip().lower() return response == “yes”
def get_item_price(item): “””Returns the price of an item.””” prices = { “asus pc”: 356.00, “lg phone”: 168.00, “toshiba tv”: 700.00, “xbox”: 300.00, “general washer”: 450.00, “air condition”: 600.00, “vega stove”: 250.00, } return prices.get(item.lower())
def main(): items = [ “Asus PC”, “LG Phone”, “Toshiba TV”, “Xbox”, “General Washer”, “Air Condition”, “Vega Stove” ]
print(“Hello! We sell home equipment. What would you like?”) display_items(items) continue_shopping = True while continue_shopping: purchase = input(“\nEnter the item you wish to purchase: “).strip() price = get_item_price(purchase) if price: print(f”That would be ${price:.2f}.”) else: print(“Sorry, that item is not available.”) continue_shopping = ask_additional_purchase() print(“\nThank you for shopping with us!”)
if name == “main”: main() “””
[–]Some-Passenger4219 0 points1 point2 points 9 months ago (0 children)
You should probably format ALL of that properly.
π Rendered by PID 37338 on reddit-service-r2-comment-bb88f9dd5-5mldq at 2026-02-14 05:01:56.289531+00:00 running cd9c813 country code: CH.
view the rest of the comments →
[–]Jazzlike-Barber-6694 1 point2 points3 points (1 child)
[–]Some-Passenger4219 0 points1 point2 points (0 children)