I found an interesting problem on https://www.codechef.com/PBK12020/problems/ITGUY16:
The chef is trying to solve some pattern problems, Chef wants your help to code it. Chef has one number K to form a new pattern. Help the chef to code this pattern problem.

-----Input:-----
-First-line will contain $T$, the number of test cases. Then the test cases follow.
-Each test case contains a single line of input, one integer $K$.

-----Output:-----
For each test case, output as the pattern.

-----Constraints-----
- $1 \leq T \leq 26$
- $1 \leq K \leq 26$

-----Sample Input:-----
2
2
4

-----Sample Output:-----
A
12
A
12
ABC
1234

-----EXPLANATION:-----
No need, else pattern can be decode easily.

I tried it in Python, but could not do it. Can you solve it?
# cook your dish here
t = int(input())

def pattern(k):
 for i in range(1, k+1):
  if i%2 == 1:
   s = ''
   for j in range(i):
    s+=chr(65+j)
   s = ' '*(26-i) + s
   print(s)
  else:
   s=''
   for j in range(1, i+1):
    s+=str(j)
   s = ' '*(26-i) + s
   print(s)
 

for _ in range(t):
 k = int(input())
 pattern(k)