Range | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Range

what I have to do here to make the code print 50 ,should I give the range method additional step like boxOf5=list(0,55,5) ? is there another way to make it? https://code.sololearn.com/c9w9gyDJeE0p/?ref=app https://code.sololearn.com/c9w9gyDJeE0p/?ref=app https://code.sololearn.com/c9w9gyDJeE0p/?ref=app

9th Oct 2017, 9:58 AM
Hmmam Babe khuoja
Hmmam Babe khuoja - avatar
2 Answers
+ 8
boxOf5=list(range(0,51,5)) print(boxOf5)
9th Oct 2017, 11:11 AM
Hatsy Rei
Hatsy Rei - avatar
0
boxOf5=list(range(0,51,5)) print (boxOf5 [10]) range (a , b-1 , c) "range" works as this example a is the initial number b is the final of the range, but list will print just until b-1; so if you put 50 at the end, the range will be: (0, 1, 2, 3, ..., 49) Because this @Hatsy have writed 50+1. Now the range will be (0, 1, 3, ... , 50). If you want print just the last term, is important to know that "c" means that your list will pull c by c terms. As the number is five, your list will be: (0, 5, 10, ... 45) term1 = 0 term2 = 5 ... term n = 5*(n-1) If you want print the number 50, chance "b" to 51 and print the 10th term of the list. boxOf5=list(range(0,51,5)) print (boxOf5 [10])
9th Oct 2017, 6:45 PM
▲TopGun ▲
▲TopGun ▲ - avatar