Allow me to break it down for you...
print(('['), (dr+1), (']\t'), (d[dr] if fullpath else '['), (dr+1), (']\t'), (d[dr].split("/")[len(d[dr].split("/"))-2]), sep='')
See the problem?
print(*(('[',dr+1,']\t', d[dr]) if fullpath else ('[',dr+1,']\t', d[dr].split("/")[len(d[dr].split("/"))-2])), sep='')