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

Recommended Answers

All 6 Replies

.split(',') the user input.

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

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

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: ")

See "List operations" here.

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.

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.