The following is not clear and most probably your error:
Are you trying to have 2 loops there? What your code is doing is the following:
It runs a loop on i, then it assigns k a range between 1 and 2, then calls a subplot with the value of k, which prompts an error as you should have a single value.
Perhaps you need the following: