How to convert a for from C to python, "It has to be programmed in c"

0

I'm totally new to C and I need to send it to call a .txt and identify where a For is found, once that is identified for converting it into a python language

example: My txt will have the following:

#include <stdio.h> 
  int main()
 {   int contador;
 for ( contador=0 ; contador<5 ; contador++ )
 printf( "%d ", contador );
 }

I have to make him analyze the document and when he finds a for it he saves it and converts it into a for in python

the program will find the for (in C language) in my document

  for ( contador=0 ; contador<5 ; contador++ )

Now I need to save that for to convert it to python the result would be something like that.

  for  i in range (0,5):

once I change that, save it in another document with the modification made.

I'm only interested in that line what is inside the for not interested me, I have searched how to call the .txt but I do not know how to save the line in a variable or an array to compare, modify or change it I hope you can help me I can not with this :(

This is my problem is how to detect the for and then change it to code in python

I do not want to do all this, I do not need to declare or send to print

      contador = int()
      for contador in range(6):
           print contador

I'm only interested in changing this line which would be the for in c

    for ( contador=0 ; contador<5 ; contador++ )

for this line that would be in python

    for contador in range(6):
    
asked by David 02.12.2017 в 21:54
source

1 answer

-1

Your code in Python would look like this

contador = int()
for contador in range(6):
    print contador
    
answered by 02.12.2017 в 22:02