How to Get First N Items from a List in Python 26/01/2024 • python • Por Alfonso Sánchez Uzábal test_list = [1, 2, 3, 4, 5, 6, 6] N = 2 # using list slicing # Get first N elements from list res = test_list[:N] Fuente Ir al contenido original Compartir