Can someone help me convert the following C++ code to python, please. I am fairly new to python.
void main()
{
int i,j,cnt,l,count[50]= {0};
char str[50];
clrscr();
printf("Enter the string: ");
scanf("%s",str);
printf("\n\tOriginal String is: %s",str);
printf("\n\n\tEncoded String is: ");
l = strlen(str);
for(i=0; i< l; i*=1) {
j = 0;
count[i] = 1;
do {
j++;
if(str[i+j] == str[i])
count[i]++;
}
while(str[i+j]==str[i]);
if(count[i]==1)
printf("%c",str[i++]);
else {
printf("$%d%c",count[i],str[i]);
i += count[i];
}
}
getch();
}
/************************* OUTPUT ************************
Enter the string: sleepzzzzzzzzzzzzzzzzzzz
Original String is: sleepzzzzzzzzzzzzzzzzzzz
Encoded String is: sl$2ep$19z */