This site has a big collection of
Tutorials. You may find it helpful to take the time to look through them and study the ones which cover areas that you don't understand. For your immediate problem, see:
I also suggest that you get in the habit of testing each little piece of your program from start to finish and fixing each piece as you go along, rather than assembling a lot of stuff and then hoping to get it to all work somehow. This way getting a small project like your password generator to work will take minutes to hours rather than days. You will eventually be able to write larger chunks of code at a time as you gain confidence in what works and what doesn't.