Don’t copy code unless you understand what it does.
I remember my IT teacher didn’t like when I copied code from the internet, I did not understand what it did, that’s not coding, that just ripping off someone elses work. Only when you understand what it does should you copy it and modify it, also give credit to the person who made it in the first place.
Taking inspiration is fine though, as long as you know what the code does and how it works.