Does this work | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Does this work

s=range(1,10) print(s) Does it give the values between the range or is there a way

21st Mar 2022, 1:42 PM
Amal Sony
6 Answers
+ 3
I think you can go with a list s = [i for i in range(1,10)] print(s)
21st Mar 2022, 1:46 PM
Faisal Issaka
Faisal Issaka - avatar
+ 3
The output will be range(1,10) And the type of s will be range
21st Mar 2022, 1:45 PM
Amirreza
Amirreza - avatar
+ 3
print(*range(1,10))
21st Mar 2022, 3:27 PM
Shadoff
Shadoff - avatar
+ 3
you can also use list constructor to get the values printed: s = list(range(1,10)) print(s) # result is: [1, 2, 3, 4, 5, 6, 7, 8, 9]
21st Mar 2022, 6:24 PM
Lothar
Lothar - avatar
+ 1
Ok, thank you
21st Mar 2022, 1:47 PM
Amal Sony
+ 1
s = range(1,10) print(*enumerate(s))
22nd Mar 2022, 6:33 AM
CodeStory
CodeStory - avatar