You need to be able to tell the
TargetWeights method two things: which stocks to trade, and, what the weight of each stock should be. (Otherwise how would it know which stocks to choose. You need to tell it).
Which tutorial are you referring to? Is it Lesson 3 'Pipeline API' (https://www.quantopian.com/tutorials/getting-started#lesson3) ?
When using a pipeline to fetch data, the data is always returned in a dataframe. The dataframe columns are whatever factors, filters, or classifiers you define. The rows are always the security objects (ie the stocks). To get a list of stocks one simply needs to turn the index into a list. Something like this:
my_list_of_stocks = pipeline.output.index.tolist()
Python and Pandas is pretty forgiving. One often doesn't need to supply a strict python list. Often times the index is fine. Just 'list like' is often good enough.
The other thing to remember is that most of the time one wouldn't want to trade ALL the stocks returned in pipeline.output. So, selecting a subset of the dataframe is quite typical. Using the 'Lesson 3' pipeline, we could take the 50 stocks with the highest 'sentiment_score' something like this:
my_best_stock_list = pipeline.output.nlargest(50, 'sentiment_score').index.tolist()
The above could also be done with filters as part of the pipeline definition. Personal preference which way one goes.
Hope that helps?