-3
tfi = '''
aardvark
albatross
alligator
alpaca
ant
anteater
antelope
'''

print(tfi)

Ok so, this is just a small section of the tfi string, but how do I make the code print this out in sections decided by amount of characters.

pseudo:

print tfi (3 chars):
returns:
    'aar'
    'dva'

and so on...

ChickenRun
  • 261
  • 1
  • 3
  • 12

1 Answers1

0

Try this:

def tfi(my_string, dif):
    for i in range(0, len(my_string), dif):
        print(my_string[i:i+dif])
neverwalkaloner
  • 46,181
  • 7
  • 92
  • 100