0

Let's say I have the following list:

nums = [10,2,3,4, 8, 3]

I want to slice and index nums so that I create a new list from only some elements of the original list. For example #1:

nums_1 = [10, 3, 4, 8, 3]

Or Example 2:

nums_2 = [10, 3, 4, 3]

Is there an efficient way to do this? I tried nums.pop() but I don't want to change the original list.

PineNuts0
  • 4,740
  • 21
  • 67
  • 112
  • How are you selecting which items go into the new list? – Galo do Leste Jan 12 '23 at 04:04
  • "I want to slice " Okay, so: figure out the rules that tell you what slices to use; make them; and put them together. What is the difficulty? – Karl Knechtel Jan 12 '23 at 04:05
  • If, for example, you want "how can I make a new list with every element except the one at a specified index?", I think there is a more specific duplicate for that. If you want to exclude multiple specific indices, that is applying the same technique multiple times, or else Needs More Focus to be answerable. – Karl Knechtel Jan 12 '23 at 04:07

0 Answers0