Ask coding questions

← Back to all posts
Python CodeHS Question
SimplyMiah

Hey guys! I’m currently writing a code that gives song suggestions if someone simply presses a key, but I’m stuck on how to use the list I made in my code, which is my_songs[ blah, blah, blah]. Can anybody please help me? Thank you!

Voters
SimplyMiah
Comments
hotnewtop
IMayBeMe

One way to do this is to create a function which is called on key press the function can look like this:

SimplyMiah

@IMayBeMe wait..so if I made a list song_options([‘blah’,’blah’,’blah]) and before that made the def function def song_options (input) : , would that be considered using my list function?

InvisibleOne

Do you want a random item from the list?

Or just select them from the list, with their index number

VulcanWM

yeah and also to get the index number of an item do:

@InvisibleOne

InvisibleOne
SimplyMiah

@InvisibleOne wait..so if I made a list song_options([‘blah’,’blah’,’blah]) and before that made the def function def song_options (input) : , would that be considered using my list function?