How to Find the max of output elements | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
4th Feb 2023, 11:07 AM
PASHA 🇷🇺
PASHA  🇷🇺 - avatar
7 Answers
+ 8
Павел Сливенко 🇷🇺 , what i am missing in this question is a clear task description that explanes how the decision about the number is done. it is this line: if (len(T1)/2==T1.count('1')): but it would be more obvious to say explicitly: > find the length of a substring (T1) based on T, where the number of 1's is equal to the length of T1 divided by 2.
4th Feb 2023, 5:58 PM
Lothar
Lothar - avatar
+ 3
The code only outputs 4 numbers. Did you mean to find max of the four or was it something else?
4th Feb 2023, 12:07 PM
Ipang
+ 3
Yes, I mean max of the four in this example. It's 90. I need the code that output only maximum value of all that this code produces. Thank you for your help.
4th Feb 2023, 2:44 PM
PASHA 🇷🇺
PASHA  🇷🇺 - avatar
+ 2
To max: a = 4 b = 2 def findTheMax(a, b): return max(a, b) To min is min()
6th Feb 2023, 4:02 AM
Gabo Guzman
Gabo Guzman - avatar
+ 1
This code can output any number of elements due to the T value.
4th Feb 2023, 12:11 PM
PASHA 🇷🇺
PASHA  🇷🇺 - avatar
+ 1
Can you please confirm my question, what is max value? I'm still unclear on that point ...
4th Feb 2023, 2:37 PM
Ipang
+ 1
Okay, Thanks for the confirmation I was thinking to create a blank `list` before the loop begin, and add variable <L> into that `list` rather than printing it on acreen. We can simply pass that `list` to max() function once the loop completed to get the largest element.
4th Feb 2023, 2:50 PM
Ipang