Question about the product of Python variables

Asked 2 years ago, Updated 2 years ago, 15 views

I'm a student who is studying Python for the first time There is a difficult part, so I would really appreciate your help.

The value of 10 20 30 40 50 is

Based on the number of cases of ABC de (5 factories, right?) (abcde, abced, abdce,abdec ....)

Is there a way to get the maximum of the product when a cde has a different value?

I think the explanation is insufficient, so if I add it,

For example,

When 20 characters from a to t have each value

We want to find an expression that can yield the maximum value of a number and an alphabet corresponding to from 1 to 20.

a*1 b*2.... a*2 b*6....and other various cases will come out.

I'd appreciate it if you could tell me how to find an expression that can get all those values ㅠ<

(The alphabet is used for convenience, and it actually requires a numerical value!)

python

2022-09-22 20:06

1 Answers

Try using the product function in itertools.

In [9]: list(itertools.product('abcd', range(1, 3)))
Out[9]:
[('a', 1),
 ('a', 2),
 ('b', 1),
 ('b', 2),
 ('c', 1),
 ('c', 2),
 ('d', 1),
 ('d', 2)]


2022-09-22 20:06

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.