How to count how many maximum numbers there are among inputted in one line values?

Question:

I’ve got 4 integer inputs in one line separated by a space, and I have to output the largest of them and how many largest integers there are, also in one line and separated by a space. The first request can be easily done with a max function, however I can’t figure out how to do the second one. Example:

Input: 6 4 -3 6

Output: 6 2

And this is code I’ve written so far:

a, b, c, d = map(int, input().split())
max = max(a,b,c,d)
print(max, )

How can I count the amount of largest integers?

Answers:

Here is a way to do it:

x = "6 4 -3 6"
l = list(map(int, x.split()))
print(max(l), l.count(max(l)))

Where x is the string that you got from the call to input().

Answered By: Hampus Larsson
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.