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::])
Previous Article

Interlace 1 to N-Pattern

Next Article

Integer K Pattern

Write a Comment

Leave a Comment

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