Really bad code from r/learnprogramming
From the post it doesn't compile.
They don't really like it when you completely write something for someone so I can't post it there.
My attempt at writing what I think the person who posted to r/learnprogramming wanted his code to do.