For solving this problem we need requests module.
For installing requests module,we need this command to get executed at command line.
pip install requests
Scraping
- Import requests module.
- Then we need to fetch data from URL.
- Using UTF-8 decode the text.
- Then convert string into a list of words.
Ordered Finding
- Traverse the list of words using loop.
- Then compare the ASCII value of adjacent character of each word.
- If the comparison is true then print ordered word otherwise store the unordered word.
Example code
import requests def Words_find(): my_url = ""#put thisurl of .txt files in any website my_fetchData = requests.get(my_url) my_wordList = my_fetchData.content my_wordList = my_wordList.decode("utf-8").split() return my_wordList def wordordered(): collection = Words_find() collection = collection[16:] my_word = '' for my_word in collection: result = 'ordered' i = 0 l = len(my_word) - 1 if (len(my_word) < 3): continue while i < l: if (ord(my_word[i]) > ord(my_word[i+1])): result = 'not ordered' break else: i += 1 if (result == 'ordered'): print(my_word,': ',result) if __name__ == '__main__': wordordered()