Python Forum
New with Python. Help with a code
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
New with Python. Help with a code
#14
(May-03-2023, 06:25 AM)jasonkeller1970 Wrote: Is it possible?
Yes it is. Try something like this
import itertools as itt

def multirange(*args):
    return itt.product(*(range(*v) for v in args))

expr = input('Insert the binomial: ').strip()
expr_func = eval(f'lambda a, b, c, d, e: {expr}')


for a, b, c, d, e in multirange((1, 4), (1, 6), (5, 8), (1, 5), (5, 8)):
    x = expr_func(a, b, c, d, e)
    print(a, b, c, d, e, x)
Reply


Messages In This Thread
RE: New with Python. Help with a code - by buran - Apr-18-2023, 12:31 PM
RE: New with Python. Help with a code - by Gribouillis - May-03-2023, 02:35 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020