Another question... I'm sorry I have so many questions

Asked 2 years ago, Updated 2 years ago, 54 views

This is the person I asked you two hours ago.
If I have to choose more than two vegetables, I would like to give a discount only on those vegetables.
ex)

 Enter product number 1
Enter product number 0 (exit)
print (existing price of vegetable number 1)

Enter product number 1
Enter product number 1
Enter product number 0
print (discounted price of vegetable number 1)

I looked for a lot of things (I thought it would be near the if door, so I looked for it first)If you pull more than once, you don't get a description of the random number function (for example, if you pull twice randomly), or anything else.
I wanted to know how to apply the discount when I picked it more than once.
ps) Thank you very much for your reply. I knew for the first time that Lambda could simply create an anonymous function. And the sep function that you mentioned as an example is a function that creates a space between characters or inserts a character in the middle.
Thank you so much for your kind reply.
I'm learning a lot.

python idle

2022-09-22 17:55

1 Answers

You cannot memorize and program all functions in the library.

In the end, you have to keep the reference next to you and continue to refer to it.

For function descriptions, refer to the link below.

https://docs.python.org/3/

To find out which items you have selected more than once, you need to save a separate history for the items you have selected, and you need to see how many of them are the same.

That is, if you select two 1, two, one, and three, the structure is as follows.

cart = ['1', '1', '2', '3', '3', '3'] 

Here, the count method can be used to obtain the number.

cart.count('1')
2

cart.count('4')
0


2022-09-22 17:55

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.