Does range function always takes one parameter? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Does range function always takes one parameter?

28th Jul 2016, 11:19 PM
Vishalvikram Singh
Vishalvikram Singh - avatar
3 Answers
+ 1
With two params, the output would look like the below. x = list(range(5, 10)) print(x) # [5,6,7,8,9] With three params, the output would look like the below--where the third param is the gap between each input. x = list(range(5, 10, 2)) print(x) # [5,7,9] Note: alphabet letters don't work with range.
31st Jul 2016, 3:53 PM
SouthBay
SouthBay - avatar
0
no
29th Jul 2016, 10:16 PM
Narek Tonoyan
Narek Tonoyan - avatar
0
# Just kidding :) step = input("Enter a number: ") x = range(0, 1000, step) print x
21st Feb 2017, 8:18 AM
Abdelkader Ait Assou
Abdelkader Ait Assou - avatar