Can a pushbutton be connected between a digital input and a digital output ?

I tried to edit my post to inform that I've learned that it was a pull-up/pull-down resistor related problem, but I failed to save.
Your answer confirms that, consider the problem solved.
I feel so noob in electronics…