Remove a list


#1

Hi,

Sorry to bother you. I have tried the answer given in "Removing from list" and several others, but it doesn't work


backpack = ['xylophone', 'dagger', 'tent', 'bread loaf']
backpack.remove('dagger')

and i get the following error message:

Oops, try again.
`backpack` has to be a list! Click Reset Code to get back to the original code

I have also tried the answer of the topic "removing a list"

 inventory['backpack'].remove('dagger')

and i get the following error message:

File "python", line 2
inventory['backpack'].remove('dagger')
^
IndentationError: unexpected indent

Could you help me please?

Many thanks,

Marc


#2

Hi try to remove the space before this line

 inventory['backpack'].remove('dagger')

#3

thanks for your fast answer.

i Have tried but now i become this:
Traceback (most recent call last):
File "python", line 2, in
NameError: name 'inventory' is not defined


#4

now can you post all your.


#5

Sorry:

...
backpack = ['xylophone', 'dagger', 'tent', 'bread loaf']
inventory['backpack'].remove('dagger')
....


#6

the error says...
NameError: name 'inventory' is not defined
it's because you didn't define inventory


#7

Hi Wizmarco,

Many thanks for your answer.

today I tried the first code that i wrote and it worked. :slight_smile:


#8

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.