Python: Fetch first 10 results from a list [duplicate]

list[:10]

will give you the first 10 elements of this list using slicing.

However, note, it’s best not to use list as a variable identifier as it’s already used by Python: list()

To find out more about these type of operations you might find this tutorial on lists helpful and the link @DarenThomas provided Explain Python’s slice notation – thanks Daren)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)