0

Infinite list in Python

I want to create a very longer list, but ,in python (i don't know in another one), the lists have a limit (24~30, i think), the question is this: Is it possible to create an infinite list(or similar)? PD: Sorry, my english is so bad😅

15th May 2020, 3:26 AM
4lx
4lx - avatar
13 Respostas
+ 4
Lists do not have a built-in limit, but your computer hardware and the Jupyter kernel has a limit of available memory. If you need to work with large amount of data, use generators, and generator expressions. Do not put all the values in a list, but evaluate them one by one.
16th May 2020, 5:39 AM
Tibor Santa
Tibor Santa - avatar
15th May 2020, 3:49 AM
Ayush Kumar
Ayush Kumar - avatar
+ 1
Yes it is possible . Just see the following code. a=0 L=[] while True : a+=1 L.append(a) print(L) It will return you a list with infinite numbers
15th May 2020, 3:46 AM
Ayush Kumar
Ayush Kumar - avatar
+ 1
I×Am×Idiot The question is not stupid at all. It is possible in Python to create infinite sequences with generators... And use as many values of that, as needed. Obviously not ALL the values (because it's infinite). An example: https://code.sololearn.com/c3DpX5B6JhXZ/?ref=app
17th May 2020, 6:45 AM
Tibor Santa
Tibor Santa - avatar
+ 1
i would have to agree that this is not a stupid question at all and is actually really deep and in inspiring. your question actually inspired me to write my own code using infinite lists... it checks whether two sequences intersect. you can see it here if your interested 👍 https://code.sololearn.com/czyFq84tGj4h/?ref=app
17th May 2020, 9:14 AM
madeline
madeline - avatar
15th May 2020, 3:29 AM
Ayush Dwivedi
Ayush Dwivedi - avatar
0
That is recursion? I meant something like that: List[0,1,2,3,4,5,6,7,8,9...]
15th May 2020, 3:38 AM
4lx
4lx - avatar
0
Ehhh... I dont understand this... A few hours ago i try a similar code in Jupyter Notebook, and the list have a limit, but now, in SoloLearn these are infinite...
15th May 2020, 3:58 AM
4lx
4lx - avatar
0
you could probably create an infinite list if u knew it was made up of some kind of pattern... like all 000s or 123s while true: print(123) but that would be kinda useless đŸ€·â€â™€ïž
17th May 2020, 2:21 AM
madeline
madeline - avatar
0
It is unnecessary to answer the question, the question is stupid, I wanted to say if it is possible to create this: list [a, b, c, d, f ... (infinite)], but i said this because when I was trying to create a long list in Jupyter Notebook, the list was truncated, but it was probably a bug or I see bad lol
17th May 2020, 2:44 AM
4lx
4lx - avatar
0
Nope, the question is stupid, the lists have no limits to append/index items
17th May 2020, 1:12 PM
4lx
4lx - avatar