I want to hide price from the related products and the upsell products block
I am going to assume that you are using version 2.4.0.
The file below is responsible for rendering those lists: related, upsell, cross-sell, etc.
The easiest way to hide the price is to overwrite it on your theme.
You can simply copy and paste the content of the core file to the file above that you must be created and then remove line 226: