Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

The way to python-fundamentals 3

Shulou Source: shulou.com Published: 2022-06-03 05:46:05 10月02日 Update

Assignment:

1. Write a blog every week

2. Write login interface

Enter user name and password

Welcome message is displayed after successful authentication.

Lock after three misses

3. Multi-level menu

Three-level menu

You can choose to enter each submenu in turn.

New knowledge points required: list, dictionary

Data = {"fruit": {"banana": {"Origin": ["Hainan", "Maldives"], "Price": [9.929.9]}, "Apple": {"Origin": ["USA" "Shandong"], "Price": [1.2] 5.5]}, "Litchi": {"Origin": ["Taiwan", "Yunnan", "Guangxi"], "Price": [9351]},} "vegetables": {"cauliflower": {"Origin": ["Hebei", "Henan"], "Price": [257,13]}, "Tomato": {"Origin": ["Huairou", "Yanqing"] "Price": [0.5],}, "seasoning": {"Soy Sauce": {"Brand": ["Haitian", "Lu Hua", "Li Jinji"] "Price": [25.5, 35.5 [15.5]]}, "edible salt": {"Brand": ["Jiuda", "White Elephant"], "Price": [5jue 9]},} } while True: for i in data: print (I) choice = input ("choose to enter 1 > >:") if choice in data: while True: for i2 in data [choice]: print ("\ t" I2) choice2 = input ("enter b to return to the previous menu or select to enter 2 > >:") if choice2 in data [choice]: while True: for i3 in data [choice] [choice2]: Print ("\ t\ t" I3) choice3 = input ("enter b to return to the menu above or select to enter 3 > >:") if choice3 in data [choice] [choice2]: for i4 in data [choice] [choice2] [choice3]: Print ("\ t\ t" I4) choice4 = input ("enter b to return to the upper layer Or enter Q to exit > >: ") if choice4 =" b ": pass elif choice4 = =" Q ": Exit () if choice3 = = "b": break elif choice3 = = "Q": Exit () if choice2 = = "b": break elif choice2 = = "Q": exit () else: print ("input does not exist.") Break

Tags: Price input origin menu selection brand success information content blog dictionary password interface fruit Haitian user user name knowledge knowledge point apple Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Xiaomi Redmi vpn Shulou Tech Info