Weird stuff coming with poop (Pic included)


Hey i have been getting this thing in my anus for quite some week. There was also some blood but now it has stopped. I went to a doctor and he gave me some meds but it didn’t stop so i went to a gastro doc and he said that it is a sign of worry. This thing happened to me a few years back but at that time too my sigmoidoscopy was normal. The gastro doc has given me new meds and has told me to come after five days to see if it gets better.
Is this dangerous?