Python Forum

Full Version: maximum and minimum element from the list and return output in dict
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi guys,

Find maximum and minimum element from the list and return output in dict i.e dict:{'Minimum : value,'Maximum':value'}

i am having a list of values
lis=[10,25,45,7,90]
i just need to find the max and min value in the list and return the output in dictionary.
This is what i tried using built in func to find the max and min value
lis=[10,25,45,7,90]
maxi=max(lis)
mini=min(lis)
but how to return those outputs in dictionary format?
When you talk about returning output, it sounds like you are meant to use a function, but that's not clear. If you are supposed to use a function, you might want to look at the function basics tutorial. Dictionaries are easy. Not only is there a dictionary tutorial here, but your assignment gives you the basic syntax already:

extremes = {'Maximum': 90, 'Minimum': 7}