I am new to python, and I have been having some difficulty as of late. The current prompt that I am working on entails:

Write a program that gets the names of a player's top-five favorite games. Your program should store the names in a list. Then, the program should display teh five game names in the list.

So far this is what I have:

list = [""]
raw_input("\nEnter your top-5 favorite games:")
print "Your favorites are:"
for item in list:
        print item
raw_input("\nPress the enter key to exit")

The problem I am having is that I do not know how to correspond the users input into the list for it to display.

Any thoughts?

Thanks,

Tyler

You are not appending the list anywhere.

Computer see's list as nothing
See's someone needs to input something
See's something being printed
See's that for every interation it will print a list of nothing
And then see's more user input.

list.append(raw_input("\n Enter you top 5 favorite games: ")

You are not appending the list anywhere.

Computer see's list as nothing
See's someone needs to input something
See's something being printed
See's that for every interation it will print a list of nothing
And then see's more user input

and likewise:

>>>r=[]
>>> r.extend((input('Three Things: ').split()))
Three Things: my uncle bob
>>> r
['my', 'uncle', 'bob']
>>>

which could be done without the initial empty list.

Edited 5 Years Ago by pyguy62: n/a

This article has been dead for over six months. Start a new discussion instead.