0

i have this code:

import random
choices = ['closet', 'lampshade', 'fridge']
print "i have hidden 10,000,000 pounds in one of these places:", choices
choice = raw_input("Where do you want to search? ('closet', 'lampshade', 'fridge')")
random_c = random.choice(choices)
while choice != random_c:
	choices.del(random_c)
	for word in choices:
		if choice == word:
			print word, "is not where it is hidden"
	choice = raw_input("where do you want to search?", choices)
print choice, "is where it is hidden well done"

but whenever i run it it comes it with this error:

> "C:\Python25\pythonw.exe" -u "C:\Python25\word_based game 1.py" 
  File "C:\Python25\word_based game 1.py", line 9
    choices.del(random_c)
              ^
SyntaxError: invalid syntax
2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by leegeorg07
0

del is a command not a method:

del lst[index]

You can also do:

lst.remove(item)

and

removed = lst.pop(index)

The second seems to be the one you want.

1

first off i wanna say sorry for blowing off before i just couldn't understand how you didn't understand why we wanted to find out
yeah thanks i realised that after i published it, i now have:

import random
choices = ['closet', 'lampshade', 'fridge']
print "i have hidden 10,000,000 pounds in one of these places:", choices
choice = raw_input("Where do you want to search? ('closet', 'lampshade', 'fridge')")
random_c = random.choice(choices)
while choice != random_c:
	choices.remove(choice)
	print choice, "is not where it is hidden"
	print "where do you want to search?"
	choice = raw_input(choices)
print choice, "is where it is hidden well done"

how can i expand this.

Votes + Comments
No hard feelings
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.