"but it doesn't work" doesn't give us much to go on. What problems are you having? Are you getting error messages? Is your program not behaving well? Also consider fixing your code indentation and...