954,515 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

user list input problem

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

Tyler212
Newbie Poster
7 posts since Sep 2011
Reputation Points: 10
Solved Threads: 0
 

.split(',') the user input.

pyTony
pyMod
Moderator
5,359 posts since Apr 2010
Reputation Points: 782
Solved Threads: 852
 

where exactly would you place the split tag in the code?

Tyler212
Newbie Poster
7 posts since Sep 2011
Reputation Points: 10
Solved Threads: 0
 

I have allready finished my course, now is your turn. You must do to learn.

pyTony
pyMod
Moderator
5,359 posts since Apr 2010
Reputation Points: 782
Solved Threads: 852
 

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: ")
paxton91
Newbie Poster
3 posts since Sep 2011
Reputation Points: 10
Solved Threads: 0
 


See "List operations" here.

woooee
Nearly a Posting Maven
2,454 posts since Dec 2006
Reputation Points: 777
Solved Threads: 714
 

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.

pyguy62
Posting Whiz
353 posts since Aug 2011
Reputation Points: 34
Solved Threads: 19
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You