Monday, October 6, 2025
HomeLanguagesPython | sympy.fromiter() method

Python | sympy.fromiter() method

With the help of sympy.fromiter() method, we can iterate over the loop and can add elements in tuples and list by using sympy.fromiter() method.

Syntax : sympy.fromiter()
Return : Return the elements from iteration.

Example #1 :
In this example we can see that by using sympy.fromiter() method, we are able to iterate over loop and can add elements in tuples and list.




# import sympy
from sympy import *
  
# Use sympy.fromiter() method
gfg = Tuple.fromiter(i for i in range(6))
    
print(gfg)


Output :

(0, 1, 2, 3, 4, 5)

Example #2 :




# import sympy
from sympy import *
  
# Use sympy.fromiter() method
gfg = List.fromiter(i for i in range(10))
    
print(gfg)


Output :

[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32338 POSTS0 COMMENTS
Milvus
86 POSTS0 COMMENTS
Nango Kala
6707 POSTS0 COMMENTS
Nicole Veronica
11871 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11936 POSTS0 COMMENTS
Shaida Kate Naidoo
6825 POSTS0 COMMENTS
Ted Musemwa
7090 POSTS0 COMMENTS
Thapelo Manthata
6779 POSTS0 COMMENTS
Umr Jansen
6782 POSTS0 COMMENTS