Substring Printer c-python convertion

Please convert the following C code to Python so that the Python program executes successfully passing the test cases.

#include <stdio.h>
#include <stdlib.h>
int main()
{
char str[101];
int len, X;
scanf("%s%nn%d", str, &len, &X);
printf("%s",str+len-X);
return 0;
}

converting the above code to python

string=input()
x=int(input())
print(string[len(string)-x::])

Leave a Reply

Your email address will not be published. Required fields are marked *

More posts. You may also be interested in.