Q:

Repeating same code block for creating different values

I'm making a program that basically calculates the missing values (x in this example) in multiple lists. 
These are the lists:
L11=[1,3,5,'x',8,10]
L12=['x',3,3,'x',6,0]
L21=[6,1,1,9,2,2]
L22=[1,1,1,'x','x','x']

For example, I'm using this code block to find the x values in L22:
#How to find x:
#1--> a= calculate the sum of integers in the list
#2--> b=calculate the average of them 
#3--> all values of x inside the list equal b

a22=L22.count('x')  
for i in range(len(L22)):
    if L22[i]=='x':
            x_L22=round((sum([int(k) for k in L22 if type(k)==int]))/(len(L22)-a22))  

So we find x_L22=1 and the new L22 is:
x_L22=1
L22=[1,1,1,1,1,1]

Now here is my question, I want to repeat this steps for all other lists without writing the same code. Is this possible?

A:

Other answers focus on extracting your current code to a generic function which is useful but isn't neither sufficient nor necessary to apply the same piece of code on multiple input.
The only thing you need is to loop over your pieces of data :
L11=[1,3,5,'x',8,10]
L12=['x',3,3,'x',6,0]
L21=[6,1,1,9,2,2]
L22=[1,1,1,'x','x','x']

inputs = ( L11, L12, L21, L22 )

for input in inputs :
    # your 4 previous lines on code, modified to work
    # on the generic "input" instead of the specific "L22" 
    a=input.count('x')  
    for i in range(len(input)):
        if input[i]=='x':
             x=round((sum([int(k) for k in input if type(k)==int]))/(len(input)-a))
    # or if you've extracted the above code to a function,
    # just call it instead of using the above 4 lines of code.

