We need help in evaluating school information performance.

Asked 1 years ago, Updated 1 years ago, 277 views

//drink=['milkis', 1000'won', ['toretta', 1200'won', ['peach green tea', 1500'won', ['fanta', 1000'won']]]

while True:
    want=input('milkis, torreta, peach green tea, and Fanta. Please choose the drink you want. : ')
    for i in drink:
        if want==i[0]:
            print(i[1])'s circle is required.')
            while True:
                ask=input('Do you want to put money in? y/n ->')
                if ask=='y'or ask=='Y':
                    money=int('input(') How much do you want to add? ->'))
                    if money<int(i[1]):
                        ask=input('Insufficient money. Would you like some more? y/n ->')
                        if ask=='y'or ask=='Y':
                            continue
                        elif ask=='n'or ask=='N':
                            break
                    elif money>=int(i[1]):
                        print ('change is', money-i[1], 'won.')
                        ask=input('Do you want to continue drinking? y/n ->')
                        if ask=='y'or ask=='Y':
                            break
                        elif ask=='n'or ask=='N':
                            break
                        else:
                            print (Please enter only 'y or n')
                            break
                elif ask=='n'or ask=='N':
                    break
                else:
                    print (Please enter only 'y or n')
            break
        elif want!=i[0]:
            ask=input('Please select only from the list. Would you like a drink? y/n ->')
            if ask=='y' or ask=='Y':
                break
            elif ask=='n' or ask=='N':
                break
    if ask=='n'or ask=='N':
        break

We need to organize a program for the school performance evaluation. So I made a beverage vending machine program. If you type Milkis in your drink, everything works fine, but if you type in the rest of your drinks, please choose only from the list. Would you like a drink? y/n ->' This part is repeated again. I've been touching it

//elifwant!=i[0]:
            ask=input('Please select only from the list. Would you like a drink? y/n ->')
            if ask=='y' or ask=='Y':
                break
            elif ask=='n' or ask=='N':
                break

I think it's repeated in my stomach because I put this in. What's the problem? To take this out, I'm in trouble because an error appears when I type something else in the name of the drink. What should I do?

python

2022-10-29 00:00

1 Answers

Now, the reason why the code we're working on isn't working properly is because:

drink = ["Milkis", 1000", won", [Toretta", 1200", [Peach green tea", 1500", ["Fanta", 1000", won]]

for i in drink:
    print(i[0])
    if i[0]!= 'Toretta':
        print('Error!')
        break

What's the problem here?

The first thing to do is not to make sure the name of the drink matches, but to make sure it's on the list provided.

And the way to do that, you'll have to make sure the name of the drink is in it, and you'll have to call the value of the name of the drink. Whatever way you use it, you can use it however you want.

y For y and n, it is more concise to use upper or lower.


2022-10-29 00:00

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.