I
I
ifuwee2020-06-17 18:17:34
Python
ifuwee, 2020-06-17 18:17:34

How to pass the index of an element to pop in Python?

box.append(shop.pop( ))
You need to pass the element index to pop. So that the product under which this index was entered by the user

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Andrey, 2020-06-17
@ifuwee

If I understand correctly, then this is how it is, but it's easier to just check the presence of the product in the list

shop = ['all', 'prod']
prod = input()
box.append(shop.pop(shop.index(prod)))

A
Anton Chernyshev, 2020-06-17
@anton206060

something like this
index = int(input())
box.append(shop.pop(index ))

S
soremix, 2020-06-17
@SoreMix

So what do you want then? It's unclear

So that the product under which this index was entered by the user
???

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question