Python Forum
maximum and minimum element from the list and return output in dict
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
maximum and minimum element from the list and return output in dict
#1
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?
Reply
#2
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}
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to sort a list with duplicates and return their unique indices. Echoroom 3 3,351 Sep-23-2022, 07:53 AM
Last Post: deanhystad
  How to remove extra space from output list? longmen 3 1,758 May-05-2022, 11:04 PM
Last Post: longmen
  Input validation for nested dict and sorting list of tuples ranbarr 3 3,840 May-14-2021, 07:14 AM
Last Post: perfringo
  List index out of range when turning CSV into dict ranbarr 15 6,278 May-12-2021, 10:38 AM
Last Post: ranbarr
  Return mean() of dict nman52 0 1,988 Apr-18-2021, 10:47 PM
Last Post: nman52
  Return the sum of the first n numbers in the list. pav1983 3 3,955 Jun-24-2020, 03:37 AM
Last Post: deanhystad
  How do you find the length of an element of a list? pav1983 13 4,786 Jun-13-2020, 12:06 AM
Last Post: pav1983
  Python Adding +1 to a list item cointained in a dict ElReyZero 1 2,035 Apr-30-2020, 05:12 AM
Last Post: deanhystad
  Dict from list - HELP! PLEASE! cherry_cherry 16 5,392 Apr-09-2020, 04:01 AM
Last Post: cherry_cherry
  How to collect all integers with minimum number of rounds? meknowsnothing 6 3,177 Jun-11-2019, 08:36 PM
Last Post: jefsummers

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020