May-11-2020, 05:25 PM
Going to post one more example. This does not have the add item. Uses terminal colors.
I was going to post the output but, I could not do it in color so, I didn't.
I was going to post the output but, I could not do it in color so, I didn't.
#! /usr/bin/env python3.8 '''Docstring''' import sys import os class FastFood: def __init__(self): self.menu_items = ['hamburger', 'cheese burger', 'fries', \ 'coke', 'coffee', 'tea', 'milkshake'] def menu(self): return f'Menu: {", ".join(self.menu_items).title()}' def order(self): on_menu = [] not_on_menu = [] return_values = [] os.system('clear') old_string = (f'\nOur Menu: \033[96m{", ".join(self.menu_items)}\033[00m') new_string = old_string.replace(',', '\033[00m,\033[96m') print(f'{new_string}\n') self.order_items = \ input('Can I take your order?\n\033[93mSeperate multiple items with a comma.\033[00m\n: ').split(',') for item in self.order_items: if not item.strip(): os.system('clear') print(f'\n\033[91m You did not order anything.\033[00m') sys.exit() if item.strip().casefold() in '\n'.join(self.menu_items).casefold(): on_menu.append(item.strip()) else: not_on_menu.append(item.strip()) os.system('clear') if on_menu: old_string = (f'\nYour Order: \033[93m{", ".join(on_menu).title()}\033[00m') new_string = old_string.replace(',', '\033[00m,\033[93m') print(f'{new_string}') if not_on_menu: old_string = \ (f'\nSorry, \033[91m{", ".join(not_on_menu).title()}\033[00m is not on the menu.') new_string = old_string.replace(',', '\033[00m,\033[91m') print(f'{new_string}\n') print() food = FastFood() food.order()
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags