Python Forum
how do i use get for my histogram function?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how do i use get for my histogram function?
#3
(Oct-13-2018, 05:46 PM)Larz60+ Wrote: get is for java in python use:
value = your_dict[your_key]
Larz, OP means
dic.get(key[,defualt]) method

@OP: what it does is to return default value if key is not present in the dict. If you don't use it, in this case you will get KeyError. So it's a nice way to return default value instead of getting error.
Now, think how you can replace the if statement using dict.get()
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
RE: how do i use get for my histogram function? - by buran - Oct-13-2018, 06:08 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question Need help with NumPy Histogram function coding Triikey 1 998 May-15-2023, 01:45 PM
Last Post: deanhystad
  Plotting histogram of dataframe column Mark17 4 2,718 Jul-30-2020, 09:52 AM
Last Post: Mark17
  Can someone find out what kind of histogram is it? J_tin 1 1,839 Apr-26-2020, 05:23 PM
Last Post: buran
  typeerror, building histogram from data newatpython11 7 3,889 Jul-17-2019, 12:54 PM
Last Post: ichabod801
  Histogram using pandas dataframe not showing proper output ift38375 1 2,249 Jul-04-2019, 10:43 PM
Last Post: scidam
  Histogram and text file. pawlo392 1 4,174 May-24-2019, 03:14 AM
Last Post: heiner55

Forum Jump:

User Panel Messages

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