Hello, I'm Still a python beginner. I've got this Assignment, and I think I've finished half of it. Can anyone help me out on this assignment. The codes I have done already are:

The assignment asks to:
Make a program that prints a list of 5 items in your house and one EMPTY space. The program then asks you to pick from a list of 3 items. The program then puts that item in the EMPTY space of your house list.

house = ["TV", "computer", "phone", "playstation", "Wii", "EMPTY"]
print "items in my house are: "
print house

house = ["TV", "computer", "phone", "playstation", "Wii", "EMPTY"]
print "Pick an item to fill in the empty space: \n1 =TV\n2 = computer\n3 = Wii\n\n"
item =raw_input("\nYou chose: ")

house[6] = item
print "Items in my house are now:"
print house

After it is done, the program is suppose to look like this:
http://i36.tinypic.com/28uu4uv.jpg

Yea, I tried my best effort. But I cannot figure out. Help would be Appreciated. thanks.

Please use code tags to wrap your code.

Your code as posted:

house = ["TV", "computer", "phone", "playstation", "Wii", "EMPTY"]
print "items in my house are: "
print house

house = ["TV", "computer", "phone", "playstation", "Wii", "EMPTY"]
print "Pick an item to fill in the empty space: \n1 =TV\n2 = computer\n3 = Wii\n\n"
item =raw_input("\nYou chose: ")

house[6] = item
print "Items in my house are now:"
print house

In line 5, you re-assign the value of house, there is no point.

From the linked picture, the options in line 6 should be things that are NOT already on the list.

In line 7, item will contain whatever the user entered. The linked picture indicates that you should be performing input validataion.

The assignment in line 9 will assign whatever the user typed, if they followed the directions it will be "1", "2" or "3". You need to do a lookup of some kind and add the appropriate item based on the number that the user entered.

Other than that, you're not too far off.

Sorry I'm also knew to this forum website, not sure about the rules..

oh okay. But the problem is I don't know what code I need to let the user assign whatever they type. :\ Can someone give me the code for "Let the user choose a option" part.. please, ty

The code item = raw_input("\nYou chose: ") prompts the user with "You chose: " and waits for the user to type characters and press return. All of the characters typed (including the return) will be in the string that is returned. In this case, you stored it in item.

It is fairly common to get rid of the extra whitespace by calling .strip() on the item or the input. For example: item = item.strip() .

Then you can compare what the user typed against the available options:

item = raw_input("You chose: ")
item = item.strip()
if item == "1":
    # they chose 1
elif item == "2":
    # they chose 2
elif item == "3":
    # they chose 3
else:
    # they chose something else

Now modify your code and try something. If you're still having problems, post your new code (using code tags) and describe what works, what doesn't and what help you would like. (More effort on your part will tend to get more help from us.)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.