Create and histogram for transcripts per gene

Hi, welcome!

Please have a look to our homework policy, homework inspired questions are welcome but they should not include verbatim instructions from your course.

Also, please understand that your code can not be run without suitable data, which is private to you.
look into the following guide for general advice how to overcome such an issue

Finally., you write that your code 'does not work very well', but I think you should be more specific about your issues with it.