Do not use ChatGPT if you are beginning coding. It does not always produce valid or good code, and if you are not experienced, you may pick up on bad habits that some people's code in ChatGPT's training set has built.
How do you know for sure? LLMs output is often plausible-sounding but incorrect - usually it's fairly obvious, but it can be subtle enough that I would not suggest using it until you've learned the old fashioned way and can better judge whether the LLM is wrong.
"Oh my god, where are my files gone ?"