English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
To solve this problem, we need the request module.
For installing the request module, we need to execute this command in the command line.
Scraping
Import the request module.
Then, we need to get data from the URL.
Use UTF-8Decode the text.
Then convert the string to a list of words.
Use a loop to traverse the word list.
Then compare the ASCII values of adjacent characters of each word.
If the comparison is correct, print the ordered words, otherwise store the unordered words.
import requests def Words_find(): my_url = ""#put this url 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()