Input a string s with a length l. Input an integer n between 1 and l . If the in
ID: 3549542 • Letter: I
Question
Input a string s with a length l. Input an integer n between 1 and l. If the input n is not in range, exit with the message "number should be between 1 and the length of the string". It is OK for the program to crash if the string given as n is not actually convertible into an integer.
Print s with all but every n-th character replaced by '.', starting with the first. Then print s again with all but every n-th character replaced by '.', starting with the second. Keep doing this until you have printed the substituted string n times. For example:
Some hints:
Explanation / Answer
string = raw_input ("Enter The String: ");
print "Your String Is : ", string
n= input("Enter n:");
print "N is : ", n
count=0
for i in range(0,n):
j=i;
pristring="."*i
while(j<len(string)):
pristring=pristring+string[j]
if(j+n-1>=len(string)):
pristring=pristring+"."*(len(string)-j-1)
else:
pristring=pristring+"."*(n-1)
j=j+n
print pristring
for indentation copy code from here
https://www.dropbox.com/s/oefdxarvbzzgjdy/kt.py
Test Run 1
Enter The String: hello world
Your String Is : hello world
Enter n:3
N is : 3
h..l..w..l.
.e..o..o..d
..l.. ..r..
Test Run 2
Enter The String: thisisastring
Your String Is : thisisastring
Enter n:5
N is : 5
t....s....i..
.h....a....n.
..i....s....g
...s....t....
....i....r...