Of course, because the act of praying is to believe that God exist, despite ones outward pronouncements otherwise. God judges the heart of a person and even if you lived a terrible life, you can be forgiven even on your death bed.
Hebrews 11:6
6 But without faith it is impossible to please him: for he that cometh to God must believe that he is, and that he is a rewarder of them that diligently seek him.