Help with Python assignment

I need to make a code which finds the highest number of a large amount of numbers. I am looking fore someone who can guide me in the right direction

An example of the numbers.
in reality I there are more than 1500
1
3633
2882
929
929
9390
142
277
838
892


What have you tried? At some point it’ll probably use the max function.

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?

I have all the numbers in the program I just don’t know where to start.

Normally I would set all the numbers in a list but 1500 numbers are a little to much for me to set in a list by hand.

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:

```python
your code
```

… like that.

If they aren’t already in a list, then how exactly are they “in the program”?

Here is a screenshot on how the numbers are arranged

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.

We have assumed that this is homework.

Please don’t solve homework, help the student learn.

Thanks a lot I will try this tomorrow

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.