Jun-04-2020, 11:08 PM
string="demoString" for ch in string: print(ch) # this for loop will post a single character #current outpput #d #e #m #o #S #t #r #i #n #g ''' my question is how to have sub-strings in output by the same functional loop (i mean is their any way to fill ch with a sub-string instead of just a single character (same functional loop mean can we use slicing for having a the sub-string-> for ch in string[::3]: # i know this will not work but i am giving you a reference for the loop <expresion>) ''' # desired output if sub string length is 3 -> #dem #oSt #rin #g