> #!/usr/bin/env python
>
> import inflect
>
> p = inflect.engine()
s1 = ''
>
> word = 'so do 1st or do 2nd or 3rd byte 4 th so do 5th longest word 3765 word 50 but 7th'
> list_word = list(word)
> print (list_word)
>
> for(m= 0; m <list_word.len(); m++):
> if list_word[m].isalpha():
> s1 += i + ''
> elif list_word[m].isnumeric():
> if (list_word[m+1].isnumeric()):
> continue
> elif (list_word[m+1]+list_word[m+2] == 'st'):
> s1 += first + ''
> m += 2
> elif (list_word[m+1]+list_word[m+2] == 'nd'):
> s1 += second + ''
> m += 2
> elif (list_word[m+1]+list_word[m+2] == 'rd'):
> s1 += third + ''
> m += 2
> elif (list_word[m+1]+list_word[m+2] == 'th'):
> if (list_word[m] == '5'):
> s1 += fifth + ''
> m += 2
> else :
> s1 += p.number_to_words(list_word[m]) + ''
> m += 2
> elif (list_word[m+1].isnumeric()):
> continue
> else:
> s1 += p.number_to_words(list_word[m]) + ''
> else:
> s1 += ' '
>
I need to convert digits to word and make a complete string with alphabets only. But the issue is this kind of for loop can not be used in Python and i need to iterate to next to next character at some places. Can I get any suggestions regarding this, please. Or if someone can suggest any other approach.