task 15 Maximum of array

Back to General discussions forum

Cicada82     2020-04-12 11:24:20

Why such a long input? For Python, entering this data is not really by hand.

I copy the data from the task and paste it

data = 'task data'  
convert_to_list = data.split()  
print(convert_to_list)

Then I substitute the list into the program

    data = []

    min_number = int(data[0])

    max_number = int(data[0])

    for i in data:

        if int(i) < min_number:

            min_number = int(i)

        if int(i) > max_number:

            max_number = int(i)

    print(min_number, max_number)

The result is not accepted as a solution. Although the code produces the correct result

Cicada82     2020-04-12 11:29:41

The code is working. I checked the result several times and it is correct. But verification does not accept the result.

Cicada82     2020-04-12 12:47:10

Sorry. Found a mistake. Entered the results on the contrary.

RobDaNub     2020-04-14 12:30:03

You should enter the data automatically.

You can use input() in Python to get each line.

It makes it a lot easier!

Please login and solve 5 problems to be able to post at forum