Answers for "how to take the range of a list in python"

4

get range of items of python list

names = ['Alice', 'Bob', 'Tom', 'Grace']

names[1:3]
# Output:
# ['Bob', 'Tom']
Posted by: Guest on April-08-2020
0

python list(range of numbers)

#range(start, stop, step)
list1 = (list(range(4)))
print(list1)

list2 = (list(range(4, 8)))
print(list2)

list3 = (list(range(4, 10, 2)))
print(list3)

list4 = (list(range(0, -5)))
print(list4)

#outputs
#[0, 1, 2, 3]
#[4, 5, 6, 7]
#[4, 6, 8]
#[]
Posted by: Guest on December-16-2021

Code answers related to "how to take the range of a list in python"

Python Answers by Framework

Browse Popular Code Answers by Language