0

Does range function always takes one parameter?

28th Jul 2016, 11:19 PM
Vishalvikram Singh
Vishalvikram Singh - avatar
3 Réponses
+ 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