Global variables can sometimes be a sign of sloppy coding
Variables can cause problems in your code if you use them both globally and locally. When you were a beginner, it made sense to define all your variables globally and program from there.
But you are now growing out of your programming infancy and your skills are growing up. This means that you are moving towards using function pipelines and local variables for each function. The trade off is that you also have to get rid of nearly every global variable as well.
Avoiding global variables creates cleaner code that is less confusing to create and understand.