+ 2

Range function output

https://code.sololearn.com/chG2URafoBYP/?ref=app is range output is list? if yes why it gives me this error

30th Mar 2018, 8:25 AM
Mina
Mina - avatar
4 Antworten
+ 3
In Python before version 3, range() return a list, and xrange() return an iterator... In Python since version 3, range() return an iterator, and xrange() does no more exist... Obviously, code playground use Python 3 ^^
30th Mar 2018, 11:29 AM
visph
visph - avatar
+ 1
Better use list comprehention: x = [i for i in range (101)]
30th Mar 2018, 10:33 AM
Sebastian Keßler
Sebastian Keßler - avatar
0
Thanks Jan Markus
30th Mar 2018, 8:33 AM
Mina
Mina - avatar
0
x=list(range(0,101)) x.append(3) print(x)
5th Apr 2018, 10:40 AM
Paul Choi