Abbreviation – Iterate in String

In this program, we will use a string as an abbreviation and make words out of it.

# at first store a string variable
my_string = 'NEWS'
# create a list for directions
directions = ['north','east','west','south']
# using for loop for each chr and pick a direction from the list
i = 0 # index initialize with zero
for chr in my_string:
    print(f'\t{chr} : for {directions[i]}')
    i = i + 1 # increment by 1