C# code convert to Python. Hello Guys, can anyone help me to convert below C# code to Python. thanks

Mkenzhe 1 Reputation point

static void Main(string[] args)
const int count = 26;
int[] ch1 = new int[count];
int[] ch2 = new int[count];

        for (int i = 0; i < ch1.Length; i++)
            ch1[i] = 1;
        for (int i = 0; i < ch2.Length; i++)
            ch2[i] = 1;

        Console.WriteLine(ch1.Sum() + ch2.Sum());
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,896 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Vicky Kumar (Mindtree Consulting PVT LTD) 1,156 Reputation points Microsoft Employee

    If I understood correct , you want to create 2 array of length 26 and assigned the value 1 individually in array ch1 and ch2 , and you want to sum all the element of array and then add both array , right?

    Equivalent Python code:

    from array import *
    ch1 =array('i',[])
    ch2 =array('i',[])

    for i in range(26)

    for i in range(26)


    Let me know if you have any doubt ?

    0 comments No comments