-1
私はGTIN-8を使ってショッピングリストを作るつもりです。私の問題は、ユーザーに数字(以下のオプションからGTIN-8コード)を入力させ、その番号を取得してプログラムを入手し、特定のデータベースで検索してその番号が等しい項目を表示します。たとえば、次のように12345670 2
におけるユーザ入力場合、プログラムは出力GTIN 8コードを使ってショッピングリストを作成
12345670 Hammer 2 4.50
Subtotal 9.00
マイコードは
があるであろう。
print("Hi There! Welcome to sSpecialists!")
print("To start shopping, note down what you want to buy and how much of it")
print("Here are the purchasable items")
print("~~~~~")
print("12345670 is a hammer (£4.50)")
print("87654325 is a screw driver (£4.20)")
print("96385272 is a pack of 5 iron screws (£1.20)")
print("74185290 is pack of 20 100mm bolts (£1.99)")
print("85296374 is a pack of 6 walkers crisps (£1)")
print("85274198 is haribo pack (£1)")
print("78945616 is milk (£0.88)")
print("13246570 is a bottle of evian water (£0.99)")
print("31264570 is kitkat original (£0.50)")
print("91537843 is a cadbury bar (£1)")
print("~~~~~")
response = input("To view more of our items type more, else no: ")
if response == 'more':
print("~~~~~")
print("45762147 is a 20 pack of sausages (£2.49)")
print("19348629 is a toy lion (£1.20)")
print("34821565 is a pack of 7 beef burgers (£1.20)")
print("48613545 is pack of 10 fish fingers (£1.99)")
print("46729811 is 500ml of heinz mayonnaise (£1)")
print("48613255 is 500ml of heinz ketchup (£1)")
print("31750677 is youghurt (£0.88)")
print("13246570 is 500ml of tropical juice (£0.99)")
print("76136948 is adult bmx bike (£499)")
print("76153242 is a sony ps4 (£249)")
print("46821799 is adult bmw i8 (£89,000)")
print("01352474 is a jar of pickles (£1)")
print("98523153 is a 20 pack of adult diapers (£7)")
print("18648515 is £20 psn card (£19.99)")
if response == 'no':
print(" ")
print("Alright, now start typing what you want to order")
print("Include the amount with a spacing")
print("For example 12345670 2 would be two hammers")
print("And when you're done, type 'END' to finish")
print("Start your orders")
print(" ")
full_list = " "
orders = []
while full_list != "END":
full_list = input("Enter your order: ")
if full_list != "END":
orders.append(full_list)
I入力にユーザ入力を取得する方法が必要GTINコードを作成し、それを書いたアイテムとしてユーザーに返します。これはPython 3.5です。
あなたのコードは、データベース駆動型ではない単なる印刷ステートメントです。私はあなたがsqliteと基本的なデータベース設計のようなものを調べることをお勧めします。あなたに正しい方向にあなたを導く例がたくさんあります。さもなければ、この質問は本当にそうではありません。 – CodeLikeBeaker