question: highest investor
ramsay is a stock broker , and N people have given him money to invest in stocks. some one may invest more money in an year. To than the person who invested most with ramsay he will send a gift at the end of the year . In case of a tie he will pick the person with the smallest lexicographic name.
Note:-
input :-
5
Harry 500
Andrew 300
Mary 1000
Jane 400
Tobey 1000
output:-
Mary 2
explanation output:- both tobey and mary have the biggest investment . as mary is smallest in lexicographic name than tobey and found at index 2 the output is "mary 2"
num = int(input(">"))
max_invest = 0
max_name = ''
invest = []
for i in range(num):
invest.append(input(str(i + 1)+">").split(" "))
large = int(invest[0][1])
for n, i in enumerate(invest):
cost = int(i[1])
if large < cost:
max_invest = n
max_name = i[0]
large = cost
elif large == cost:
if max_name > i[0]:
max_name = i[0]
max_invest = n
print(max_name,' ', max_invest)
>5
1>Harry 500
2>Andrew 300
3>Mary 1000
4>Jane 400
5>Tobey 1000
Mary 2
Comments
Leave a comment