you can call the second one item2 for example, just to differentiate comments from attachments.
Now can you try item(“attachments”).count=0 instead in the if condition?
Can you compare the count for a blank attachment and an attachment that has records?