Recursively create new Dataframe

I have a below code which i wrote It creates a new data frame for different SerialNumber character length and at the end I append all the dataframe together to get the final Output.

I am trying to find a better way writing this code. Can I do this using a for loop ?

    data["Serial Number"] = data['Serial Number'].str.zfill(28)
    print ("Fetch Serial Number with 28 characters")
    data["Output"] = data['Serial Number'].apply(lambda x: fetch_by_ser_no(x))
    data.to_excel(r'first.xlsx',index = False)
    data.loc[:,"itemlen"] = data["Output"].str.len()
    data.loc[:,"SNlen"] = data["Serial Number"].str.len()
    df = data.loc[(data['itemlen']== 1)& (data['SNlen'] == 28)]
    data.drop(data[(data['SNlen'] == 28  ) & (data['itemlen'] == 1) ].index,inplace = True)
    df.to_excel(r'raw.xlsx',index = False)
   

    data["Serial Number"] = data['Serial Number'].str.zfill(30)
    print ("Fetch Serial Number with 30 characters")
    data["Output"] = data['Serial Number'].apply(lambda x: fetch_by_ser_no(x))
    data.loc[:,"itemlen"] = data["Output"].str.len()
    data.loc[:,"SNlen"] = data["Serial Number"].str.len()
    df1= data.loc[(data['itemlen']== 1)& (data['SNlen'] == 30)]
    data.drop(data[(data['SNlen'] == 30  ) & (data['itemlen'] == 1) ].index,inplace = True)
    df1.to_excel(r'raw1.xlsx',index = False)


    data["Serial Number"] = data['Serial Number'].str.zfill(32)
    print ("Fetch Serial Number with 32 characters")
    data["Output"] = data['Serial Number'].apply(lambda x: fetch_by_ser_no(x))
    data.loc[:,"itemlen"] = data["Output"].str.len()
    data.loc[:,"SNlen"] = data["Serial Number"].str.len()
    df2= data.loc[(data['itemlen']== 1)& (data['SNlen'] == 32)]
    data.drop(data[(data['SNlen'] == 32  ) & (data['itemlen'] == 1) ].index,inplace = True)
    df2.to_excel(r'raw2.xlsx',index = False)

    data["Serial Number"] = data['Serial Number'].str.zfill(34)
    print ("Fetch Serial Number with 34 characters")
    data["Output"] = data['Serial Number'].apply(lambda x: fetch_by_ser_no(x))
    data.loc[:,"itemlen"] = data["Output"].str.len()
    data.loc[:,"SNlen"] = data["Serial Number"].str.len()
    data = data.append([df,df1,df2])

Answer for the question-:

   i = 28
    data1 = []
    while i <= 34:
        data["Serial Number"] = data['Serial Number'].str.zfill(i)
        print("Fetch Serial Number with" + str(i )+ "characters")
        data["Output"] = data['Serial Number'].apply(lambda x: fetch_by_ser_no(x))
        data.loc[:,"itemlen"] = data["Output"].str.len()
        data.loc[:,"SNlen"] = data["Serial Number"].str.len()
        
        if i != 34:
            df = data.loc[(data['itemlen']== 1)& (data['SNlen'] == i)]
            data.drop(data[(data['SNlen'] == i  ) & (data['itemlen'] == 1) ].index,inplace = True)
        else:
            df = data.loc[(data['SNlen'] == i)]
        data1.append(df)
        i = i + 2