Well, what problem are you running into at the moment? For example, do you have the numbers in the program already? Do you need to get them from somewhere? If so, do you know how to do that?
Given that you “have all the numbers in the program”, then you should not have to “set in a list by hand”; you should be able to do that programmatically, given a little help.
Why not post a sample of your code that includes a small set of the ‘numbers’ so that we can see what you have and guide you in the correct direction.
When posting your code, you’ll need to format it, pre-posting:
To make a list, put numbers = [ on a line above the first number, a comma after each number, and ] after the last number. You could write a program to do this.
(EDITED after seeing title)
Does the assignment allow you to use the builtin max function? Or are you supposed to write your own code to find the max?
When they said “in the program”, they probably meant “in a data structure”.
If there are going to be lots of numbers, you probably don’t want to have them in the code of your script.
Maybe you have them in a file numbers.txt, for example, with one number per line, or maybe there are empty lines.
You could do
maximum = float('-inf') # The smallest float. If you intend the numbers to be integers you will need to set a different default value here, or check the requirements for what would they want to return when the list of numbers is empty.
with open('numbers.txt', 'r') as infile: # Opening the file for reading
for line in infile:
try:
maximum = max(maximum, float(line.strip())) # strip removes newline character, but maybe turning the line into a float still fails, for example, if the line is empty.
except ValueError: # This is the exception that will be raised when the content of the line cannot be turned into a number. We do nothing when that happens and keep on reading further lines from the file.
pass
# Now `maximum` contains the maximum value.
One can only learn that which is outside, but sufficiently close to the horizon of what one currently understands. When the current knowledge is very limited (see those numbers written directly in a main.py file), then one learns best by imitation.
The comments inside the code are doing the “help the student learn”. More details could be added, if they ask.
Also homework is not the same as individual work. “Solving someone’s homework” is only a problem if the instructor who assigned the homework intended it as an evaluation of individual work. If that is the case, then not my problem. The instructor is the one at fault, for not knowing the role of homework in education.