iMac 2017 5k host, iMac 2017 21 target display mode
Neither of your Macs support target display mode. Below are the Macs that do.


iMac (27-inch, Late 2009)  
iMac (27-inch, Mid 2010)  
iMac (Mid 2011-Mid 2014)  


For more information see Use your iMac as a display with Target Display Mode.