+ 2
How to transfer range number to list ?
How to transfer range numbers _ 1 2 3 4 5 To list ??? https://code.sololearn.com/cs6tK7hyeM9L/?ref=app
14 Answers
+ 5
You can try with append function
n=int(input())
list=[]
for i in range(n):
list.append(i)
print(list)
+ 8
my_list = list(range(1, 10))
print(my_list)
+ 4
my_list = list(range(1, 10))
I know that , but i don't say this please see the code
+ 3
+ 3
🔰 Arit Dey 🔰 try updated code
https://code.sololearn.com/cPlksgYK3Q5o/?ref=app
+ 2
what do you mean? please provide an example
+ 2
Aditya it's really good your code is properly work in my code thanks bro
+ 1
Aditya ok i will try your code
+ 1
SAN i know it
+ 1
But i will need first print range thin print range numbers in list
+ 1
try
i_list = range(1,5+1)
[print(item) for item in i_list]
then
print(list(i_list))
+ 1
Hello the easiest way is use extend ,correct code below
list=[]
list.extend(range(5))
print(list)
+ 1
Arit try the code i provided it is the easiest way
- 1
li = range(5)
print(list(li))
for i in li:
print(i)